• 0

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


Question

Posted · Report post

Hi, 

 

 

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.

 

 

Secondly,

 

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

3 answers to this question

  • 0

Posted · Report post

Hi,

 

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 - http://codex.wordpress.org/Conditional_Tags

 

However, imo, the simplest method would be to use a plugin such as http://wordpress.org/plugins/the-loops/

 

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
  • 0

Posted · Report post

 

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 - http://codex.wordpress.org/Conditional_Tags

 

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

Simplified version of my Section:

<?php
/*
	Section: Ketri special category loop
	Author: Ketri
	Author URI: http://www.pagelines.com
	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;
	}

	 query_posts(array( 
        '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; ?>
</div>
<?php endwhile; ?>
<?php else : ?>
	<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
		<h1>No posts found in this category...</h1>
	</div>
<?php endif; ?>
<?php wp_reset_query(); // reset the query ?>
		<?php
	}
}

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

If you want to add custom options to a custom section you should follow the instructions on our developer documentation - http://docs.pagelines.com/developer/section-api

 

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