• Is there a way to be able to get my custom post type posts to show up in the featured area and blog feed? I got my custom posts to show up in the blog feed using a child functions.php file but the category banner doesn’t show up and I have no idea about the featured section.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Pearl

    (@pgrobin)

    OK – update. Still haven’t figured out how to get custom posts to add to the featured section but for anyone trying to get their custom posts and categories to show up in their blog feed – here is the code I used below.

    <?php
    // Show posts of 'post' and '<strong>your_custom_post_name</strong>' post types on home page //
    
    add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
    
    function add_my_post_types_to_query( $query ) {
    if ( is_home() && $query->is_main_query() )
    $query->set( 'post_type', array( 'post', '<strong>your_custom_post_name</strong>' ) );
    return $query;
    }
    
    function reg_cat() {
             register_taxonomy_for_object_type('category','<strong>your_custom_post_name</strong>');
    }
    add_action('init', 'reg_cat');
    
    function init_category($request) {
        $vars = $request->query_vars;
        if (is_category() && !is_category('Blog') && !array_key_exists('post_type', $vars)) :
            $vars = array_merge(
                $vars,
                array('post_type' => 'any')
            );
            $request->query_vars = $vars;
        endif;
        return $request;
    }
    add_filter('pre_get_posts', 'init_category');
    
    php?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Theme Author MyThemeShop

    (@mythemeshop)

    Hi,
    Unfortunatly here can provide only basic support for plugins.

    PS: We will do our best to provide support through the WordPress forums. However, all theme support is provided in our forum. If you have not registered yet, you can do so here: https://mythemeshop.com/go/signup/index/c/free. After searching the knowledge base and forum if you are still stuck, feel free to open a new thread, and a member of our support team will be happy to help. Cheers!
    Support link: https://community.mythemeshop.com/forum/general-support/support-for-free-themes

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Posts in Featured Section and Blog Feed’ is closed to new replies.