• eshwarspy

    (@eshwarspy)


    hi how to include custom posts in features slider with regular posts.

Viewing 6 replies - 1 through 6 (of 6 total)
  • bdbrown

    (@bdbrown)

    Hi eshwarspy. I haven’t tested this but it should work. Copy /inc/featured.php from the parent theme to the same path in your child theme. Then modify the query at the beginning of the code to include the post types. The type ‘post’ is the default but you need to include it if you’re adding other types. Also note that you need to add a comma to the end of the line before post-type:

    <?php
    // Query featured entries
    $featured = new WP_Query (
      array(
        'no_found_rows'	=> false,
        'update_post_meta_cache' => false,
        'update_post_term_cache'	=> false,
        'ignore_sticky_posts' => 1,
        'posts_per_page' => ot_get_option('featured-posts-count'),
        'cat' => ot_get_option('featured-category'),
        'post_type' => array( 'post', 'my-custom-post-type' )
        )
    );
    ?>
    Thread Starter eshwarspy

    (@eshwarspy)

    hi bdbdrown it worked, but custom posts appear in featured slider as well as content area (below slider section). how can i exclude it from content area. i dont want to show posts which featured in slider and only include remaining custom posts

    bdbrown

    (@bdbrown)

    Check Theme Options > Blog > Featured Posts and make sure “Include featured posts in content area” is not checked.

    Thread Starter eshwarspy

    (@eshwarspy)

    above u mentioned is only working for blog posts, not for custom posts. it apeears in both featured and content. i dont want posts which appeared in featured again in content.

    Thread Starter eshwarspy

    (@eshwarspy)

    hey i got solution, added function

    /* Include or exclude featured articles in loop
    /* ———————————— */
    add_action( ‘pre_get_posts’, ‘alx_pre_get_posts’, ‘custom post name’ );

    Hi Eshwarspy. I’m trying to get the same to work with my custom post type ‘event’. So to clarify, should your;

    add_action( ‘pre_get_posts’, ‘alx_pre_get_posts’, ‘custom post name’ );

    instead be:

    add_action( ‘pre_get_posts’, ‘alx_pre_get_posts’, ‘my-custom-post-type’ );

    or in my case:

    add_action( ‘pre_get_posts’, ‘alx_pre_get_posts’, ‘event’ );

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to include Custome Post Types in Featured Slider’ is closed to new replies.