Custom Post Types, Custom Meta Boxes, Single Templates, Custom Post Loop

4 posts in this topic




Before DMS—in themes—I would normally create (single-POSTTYPE.php) files and WP would know to pull that template to display the information for that post type.


I've read through every thread on the forum about custom post types and I understand there are several ways to approach displaying the information of custom meta boxes. (via plugins, short-codes, or editing functions.php of a child theme)


I've downloaded the customize-plugin, and I figured out to edit the functions.php in there to add hooks.


If I understand correctly, hooks allow you to swap out information (filters), or add new information (actions).


For instance, using (filter) hooks I can replace (post_author) with (custom_meta_field_A). Or using (action) hooks I can add (custom_meta_field_B) after (post_title).


What I don't understand is how you can use hooks to build templates for certain post types. I don't want my hooks to apply to all single posts, only for certain post types. I am basically asking how do I create the DMS equivalent of (single-POSTTYPE.php) files.





How can I create a page that shows a custom loop of certain post types? using hooks? 

Share this post

Link to post
Share on other sites



If you want to do that would probably want to create either your own custom post loop section, you could also use hooks and using the following in your hook -


However, imo, the simplest method would be to use a plugin such as


Which supports custom post types. You could also check the MiniLoops plugin too.


You can also just create a custom template for that Post type, by actual creating the template whilst on that post type. When creating that template, be sure to set the sections to type instead of local, this will then set that configured section to display the same way for the post type rather than the singular.

Share this post

Link to post
Share on other sites


If you want to do that would probably want to create either your own custom post loop section, you could also use hooks and using the following in your hook -


How can I add a similar Configure Full Width Post Metabar -field to a custom post loop section?

Simplified version of my Section:

	Section: Ketri special category loop
	Author: Ketri
	Author URI:
	Description: Custon post type loop
	Class Name: PLKETRI
	Workswith: templates, main, header, morefoot, content
	Cloning: true
	Filter: component
	Loading: refresh

class PLKETRI extends PageLinesSection {
	function section_opts() {
		$opts = array(
		return $opts;

        'post_type' => "movies",
        'showposts' => 10 
    ) );  
if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
		<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
		<?php the_content(); ?>
		<?php echo $catOrCMP; ?>
<?php endwhile; ?>
<?php else : ?>
	<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
		<h1>No posts found in this category...</h1>
<?php endif; ?>
<?php wp_reset_query(); // reset the query ?>

Share this post

Link to post
Share on other sites

If you want to add custom options to a custom section you should follow the instructions on our developer documentation -


However, I am not entirely sure what you're trying to do, why don't you just use hooks ?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Modify WP Loop Section to Display Posts and Pages?
      By eusebius+
      I recently added a function that allowed me to use the same tag taxonomy for both posts and pages. Thank God, it is working well.
      Now, I want to modify the standard post loop in the WP Loop section to show both of those post types whenever I navigate to the archive of one of those tags. After researching a bit, I found what I believe is the right code from the Codex and have tried to include it in section.php of my overridden section, but it doesn't seem to work. Here is what I have beginning from about Line 156:
      /* * Standard loop. */ // The Query function standard_loop() { $args = array('post_type' => array( 'post', 'page' )); $query = new WP_Query( $args ); if( $query->have_posts() ) while ( $query->have_posts() ) : the_post(); the_content(); endwhile; } function loop(){ $count = 0; global $plpg; if( have_posts() ) while ( have_posts() ) : the_post(); $count++; $format = get_post_format(); What am I doing wrong?
      Thanks in advance.
    • Page Title Section
      By King Creative Design+
      WordPress 4.2.2
      DMS2 Version:
      Skeleton theme

      Site URL -

      1.) I'm working with the Page Title Section and it looks like it might do what I want it to do, but if so I can't figure out which settings to use.

      2.) I have the Page Title section set up on the 'default page template', which i'm using for most pages on this site, as they all have the same layout.

      3.) I need every page to have a different title (obviously, hence why I'm using the section) but I want them to be different from what the page title is in the actual WP page doc. I see that there is there is an override in the DMS editor for this section, however when I change it, it changes all pages globally. Is there a way to do this so every page can have it's own separate overridable title?
      4.) Currently it appears how I want it to because I have done a workaround by naming the WP pages (from within the WP dash) what I need them to say. The beauty of this workaround was that the client would not have to open the DMS editor to make changes to these titles and could edit them right from the WP dash, however I have discovered that it will mess with the site search function as well as not being ideas for SEO.
      5.) I'm open to using a different section to achieve this effect so If you have another solve or a different section that might work better, please let me know.
      Thanks in advance!

    • How can I Translate the "read more" in the loop?
      By DonRicardoRVM
      First of all, sorry for my bad english.
      I have a problem that I never could solve: I can´t translate the words "READ MORE" in the loop. Where must I translate them?
    • Post Loop
      By zvkpr
      Hello there, 
      Recently I've been working on my 2nd web design with DMS2,
      it's a blog page with some music news and events so I want to 
      customize the Post Loop so in the front page it has the features 
      of Post configuration as the Flipper. 
      So I remembered that on the youtube channel there were some 
      tutorials about customizing extensions. But it has been a week
      since I can't find neither the channel or the video tutorials.
      I hope there would be more info for developers, and more 
      extensions for the club, so it really worth it.
      DSM2 it's an amazing platform for building websites. But there's
      not enough investment to satisfy developers needs.
      My best regards to the Pagelines team. 
    • Create 2 additional pages that will work with like a blog template
      By B1Guy
      I am trying to have my post show up on more than the static page that is defined in >settings>reading.
      I would very much like the post to able to be displayed on 2 other pages "like a second and third recent posts that is displayed like a blog.
      Any help would be great.
      I am somewhat familiar with how coding works but not advanced enough to write the code I think I need for this.
      is there an easier way.