Jump to content

Archived

This topic is now archived and is closed to further replies.

lexlex88

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

Recommended Posts

lexlex88    0
lexlex88

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
Danny    1,327
Danny

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.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
ketri    7
ketri

 

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
Danny    1,327
Danny

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 ?


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

  • Similar Content

    • Timothy
      By Timothy+
      Question! Does anyone know how to display a full post rather than the excerpt on the posts page? Normally I can replace 'the_excerpt' with 'the_content' on the page template, but i'm not finding that in the Framework templates...
      Thoughts?
    • flourishdesignstudio
      By flourishdesignstudio
      I am working on a site that uses post categories to organize a large collection of cocktail recipes (such as 'Fall Cocktails', 'Winter Cocktails', 'Spring Cocktails', and 'Summer Cocktails'). I am trying to style the category pages so that a user will land on the Fall page and see the fall posts in a two-column setup. The Pagelines Content section has no real post display options to speak of so I am trying to work within the Loops section, which does produce the overall visual effect that we are hoping for. However, it means that I have to create a Loops section for every single category page and tell it to show the posts for that specific category (Fall posts on the Fall Category page, Spring posts on the Spring page, etc). We actually have about 25 cocktail categories so creating unique pages for each category isn't going to be very time effective for us - especially if we want to change a setting later and have to go to each page to do that.
      So, my question is whether or not there is a way to control general category pages or if there are any other good post loop options that you recommend. This used to be much easier in the past versions of Pagelines and DMS so I just want to make sure I am not missing something within this new system.
      Thanks so much for the help!
    • huskers2011
      By huskers2011+
      I just upgraded to the platform 5 and all my post lop content in static pages is not visible on the site, although it is  selected in the page setup. 
    • micstepl
      By micstepl+
      When inserting a LOOP-Section within a WORDPRESS-Section (Pagelines Framework Content) >>> Images (loops_media) do not show. 
      (same section outside, works well)
    • MissT
      By MissT+
      Hi there, the Filter By option within the Masonic section isn't working when a custom post type and custom category is selected.  If you swap to normal posts and categories then it works but sadly not with custom post types and custom categories.
      All posts are shown but when you click on the categories all posts disappear even though posts do have these categories. When you click All all the posts come back. I've tried this on two different websites with the same result.
      Many thanks in advance.
×