• 0

Custom Post Types In Postloop?


Question

Posted · Report post

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

11 answers to this question

  • 0

Posted · Report post

@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.

Share this post


Link to post
Share on other sites
  • 0

Posted (edited) · Report post

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');
Edited by bfrye26

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thanks bfrye26.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

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

Posted · Report post

Rob"] @[member="davekeys I am happy to help!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

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

Posted · Report post

Excellent.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

davekeys what plugin may i ask?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

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

Posted · Report post

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

Posted · Report post

:)

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