• Resolved caroline

    (@makeupedia)


    I tried different codes in my function.php, but i’m still unable to make this work. I switched the plugin on and off, also inserted the register code directly into my functions.php and removed it from the CPT plugin.
    I tried with another CPT that are still in the CPT plugin, nothing works.

    I also added these two lines right after register_post_type( 'produkt', $args ); in my functions.php:

    global $wp_query;
    $query = $wp_query;

    These are some of the codes I tried:

    function my_cptui_add_post_types_to_rss( $query ) {
    // We do not want unintended consequences.
    if ( ! $query->is_feed() ) {
    return;
    }
    
    // Replace these slugs with the post types you want to include.
    $cptui_post_types = array('prod');
    
    $query->set(
    'post_type',
    array_merge(
    array( 'post' ),
    $cptui_post_types
    )
    );
    }
    add_filter( 'pre_get_posts', 'my_cptui_add_post_types_to_rss' );

    _________________________________-

    function myfeed_request($qv) {
        if (isset($qv['feed']) && !isset($qv['post_type']))
            $qv['post_type'] = array('post', 'prod');
        return $qv;
    }
    add_filter('request', 'myfeed_request');
    
    function prod_in_home_loop( $query ) {
    if ( is_home() && $query->is_main_query() )
    $query->set( 'post_type', array( 'post', 'prod') );
    return $query;
    }
    add_filter( 'pre_get_posts', 'prod_in_home_loop' );

    _______________________

    What am I missing here?

    Thanks! Caroline

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter caroline

    (@makeupedia)

    Ok, update! It did work on the CPT that I’m do not intend to use :/

    Sadly I removed the CPT I wanted to use from the dashboard and only used the code in my functions.php.

    Are there by any chance I can get it back to the CPT dashboard again or make it work anyway?

    Thread Starter caroline

    (@makeupedia)

    Ah! I managed to make it work!

    This line was missing from my code in $args = array():
    'query_var' => true,

    🙂

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Glad to hear that it looks like you got this working in the end.

    Let us know if you need anything else 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add CPT product to main blog feed’ is closed to new replies.