Forums

query to wp_query() to get content for categories and pages/posts (1 post)

  1. tim2
    Member
    Posted 5 months ago #

    I want to get content/excerpts of posts alongwith title on categories pages, how to change query object? currently i get excerpt of posts on my posts or pages. i want to show same output on categories pages too.
    $query_opts = apply_filters('yafpp_get_featured_posts_query',array(
    'post__in' => $featured_arr,
    'posts_per_page' => $yafpp_opts['max_posts'],
    ));
    if ( isset( $opts['post_type'] ) ) $query_opts['post_type'] = $opts['post_type'];
    $featured_query = new WP_Query($query_opts);
    while ($featured_query->have_posts()) {
    $featured_query->the_post();
    add_filter('excerpt_length', 'new_excerpt_length');
    // define some vars
    $the_title = get_the_title();
    $the_permalink = get_permalink();
    $the_excerpt = get_the_excerpt();
    }
    See full code

Reply

You must log in to post.

About this Topic