WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How do i filter posts in Home page. (1 post)

  1. santosh.sahoo
    Member
    Posted 3 years ago #

    I want to display only some specified posts in the home page , instead of all posts.

    I have the id of all the post that i want in the home page.

    How do i do it with wp_query or query_post(); ?

    By using the following code , i am getting the result but the gallery does not comes in the posts.
    Have a look.

    function exclude_category( $query ) {
    
    	$ids=get_option("Fpost_list");
        if ( $query->is_home ) {
           	 $query->query_vars["post__in"]=$ids;
        }
    
        return $query;
    }
    
    add_filter( 'pre_get_posts', 'exclude_category' );

    The above code works , but i cannot understand why the gallery doesnt shows up.

    Any correction or suggestion would be wonderful..

    Thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic