WordPress.org

Forums

Expound
Limiting number of featured posts (4 posts)

  1. matatias
    Member
    Posted 1 year ago #

    Hi. I've created a section that shows posts only from one category, and managed to exclude that category from the homepage and featured posts (that's how I did it: http://wordpress.org/support/topic/exclude-certain-categories-from-featured-posts?replies=3)
    Now my problem is the excess of featured posts. I have that main big featured post, and instead of 4 secondary posts, I have 9! So I think Expound is "generating" 10 featured posts.
    I'm suspicious of this line in the functions.php file:
    $count = apply_filters( 'expound_featured_posts_count', 5 );
    Changing that "5" worked before I made that changes. Now it doesn't change anything.
    Any advice?

  2. matatias
    Member
    Posted 1 year ago #

    I added one line to the functions.php file (it was too late to use a child theme, I'll set up one later):

    function expound_get_featured_posts() {
    //the line I added to filter a category
    	return new WP_Query(array('category__not_in' => (8) ) );
    
    	global $wp_query;	
    
    	// Default number of featured posts
    	$count = apply_filters( 'expound_featured_posts_count', 5 );

    When I delete that line, the theme returns to normal (1+4 featured posts, but including the category "8").

  3. Konstantin Kovshenin
    Участник
    Theme Author

    Posted 1 year ago #

    The line that you have added is running and returning a new query, completely ignoring everything else in the function. Take a look at the original expound_get_featured_posts() function in the parent theme, that's how your child theme function has to look, with the addition of category__not_in to the arguments array.

  4. matatias
    Member
    Posted 1 year ago #

    Thank you very much, Konstantin! I added the line here:

    if ( empty( $sticky ) ) {
    		return new WP_Query( array(
    			'posts_per_page' => $count,
    			'ignore_sticky_posts' => true,
    			'category__not_in' => (8),
    		) );
    	}

    And it worked as I wanted. Thank you again!

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic