Jump to content

Archived

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

davekeys

Custom Post Types In Postloop?

Recommended Posts

davekeys    4
davekeys

Is there a way to get custom post types to show up for use in the postloop component? 

 

I tried flipper too, because it worked before in another DMS website but not this time.

Share this post


Link to post
Share on other sites
bfrye26    3
bfrye26

davekeys This is actually not hard at all. You have to add two little things to your functions file to have it all load in:

 

This will add the custom posts to your overall site:

add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
  if(is_category() || is_tag()) {
    $post_type = get_query_var('post_type');
	if($post_type)
	    $post_type = $post_type;
	else
	    $post_type = array('post','gamereview','moviereview','comicreviews','hardwarereviews','artricles','podcast','video','nav_menu_item');
    $query->set('post_type',$post_type);
	return $query;
    }
}

This will add the custom post types to your front page:

add_action( 'pre_get_posts', 'add_custom_post_types_to_home_page' );
 
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
    if ( is_home() && $query->is_main_query())
        $query->set( 'post_type', array( 'post','yourposttypes' ) );
    return $query;
}

this will add the custom posts to your feed:

function myfeed_request($qv) {
	if (isset($qv['feed']) && !isset($qv['post_type']))
		$qv['post_type'] = array('post','gamereview','moviereview','comicreviews','hardwarereviews','artricles','podcast','video');
	return $qv;
}
add_filter('request', 'myfeed_request');

Share this post


Link to post
Share on other sites
Rob    547
Rob

Thanks bfrye26.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
davekeys    4
davekeys

Thank you! I'll get this done. I have a feeling it's perfect from what I've read on this issue so far.

Share this post


Link to post
Share on other sites
Rob    547
Rob

@davekeys  Just make sure to add that code to the functions.php in the base child theme or in pagelines-customize.  Don't, under any circumstances add it to the functions.php in your core files.  When next we push an update your changes will be overwritten unless in a protected area, such as the base child theme or pagelines-customize.  Those two things are exempted from updates, and thus protect you from losing your work.

 

Lastly, there are a number of plugins that will do this as well.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
davekeys    4
davekeys
Thanks for that reminder. I didn't quite get the code to work but I found a plugin that did the trick.

Share this post


Link to post
Share on other sites
Rob    547
Rob

Excellent.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
davekeys    4
davekeys
This did the trick: Custom Post Type Shortcode
Deactivate | Edit
List custom post type posts using shortcode with any page or post. For documentation on how to use this plugin please visit the Blackbird Interactive Blog

Version 1.4.3 | By Blackbird Interactive | Visit plugin site

Share this post


Link to post
Share on other sites
davekeys    4
davekeys
bfrye26 Sorry to take so long to get back to you. Drowning in workload here! Good problem, right?

Share this post


Link to post
Share on other sites
Rob    547
Rob

:)


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites

  • Similar Content

    • Queue-it
      By Queue-it+
      Hi,
      How can I remove the "next post" links below each post page? 
      https://queue-it.com/cdn-blog/
      Before we had a related post section, but I can't find it among any functions, widgets etc. 

    • lutz
      By lutz
      Hi everybody,
      I use Pagelines for some years now, but for the first time I have to split up posts into several pages.
      Unfortunately, <!-- nextpage --> doesn't work.
      Can please someone help me, making that work?
      I don't have the time to change the theme and need the post split up because it would be way too long, espcially on mobile displays ...
      Thanks in anticipation!!!
    • Louis
      By Louis
      Hi, thanks for making such a wonderful theme :)
       
      I set my website up nearly exact as I like it. 
       
      Only problem is that on the homepage my post's text is indented as if there was a widget area in the left side but I only have one for the right side.
       
      Here is what it looks like on the home page: www.gutjourney.com
       
      When you click on the post, it looks like how I wish it looked (width wise)  (I still want to continue with the post previews on my home page). 
       
      Can someone help me make my posts on my homepage line up to the left of my logo the same way they do on the actual post's page?
       
      Thank you!
       
      Louis
    • JimP
      By JimP
      Hi there - 
      First Question;
      I have changed the settings in the WP Dashboard/Settings/Reading for each article to "For each article in a feed, show" "Full Text"
       
      However, only a summary version of the post shows up here; http://dwelltrade.com/blog   I would like to either
       
      1) increase the amount of the post that is visible. Can I quantify by # of pixels or ?
       
      or 
       
      2) have the whole post visible in the main blog navigation window. 
       
      Second question;
      When I click on a blog post, the blog header image, "disappears" on the individual blog post page such as; http://dwelltrade.com/italy-wine-cheese
       
      Is there any easy way to ensure the main blog page image, is included at the top of all posts, categories URLS?
       
      Thanks in advance  - I'm new at this. 
      Jim
       
       
    • bloom1creative
      By bloom1creative+
      Hey
       
      Having issues with the PostNav section.  I'm using it on custom post types with your Docker plugin, but on the first and last post of each Post Type, it displays the previous post and next post as a clone, so there are two of the same one.  You can see it on the following link:
       
      http://www.ramemarketing.co.uk/contentstrategies/the-rame-blog/16-reasons-to-invest/16-reasons-invest-content-marketing/
       
      Many thanks
       
      Rob
×