Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1084597
    Gee R
    Participant

    Hi,

    Apologies in advance as I’m sure this has been asked many times before, but I can’t seem to find the right thread to help me.

    On the blog index page, I want to display posts from only one category (in my case “news”) and exclude other blog posts tagged with other categories.

    #1084806
    Thai
    Moderator

    Hi There,

    TO achieve that, please add the following code under functions.php file locates in your child theme:

    function my_home_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '123' );
        }
    }
    add_action( 'pre_get_posts', 'my_home_category' );

    After that replace the 123 number with your news category.

    Hope it helps πŸ™‚

    #1084821
    Gee R
    Participant

    Thanks – but that’s not working πŸ™

    #1085004
    Thai
    Moderator

    Hi There,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thanks.

    #1085009
    Gee R
    Participant

    Thanks, but I’ve solved the issue in another way: by using “The Grid”.

    πŸ™‚

    #1085205
    Thai
    Moderator

    Glad you’ve sorted it out.

    If you need anything else, please let us know πŸ™‚

  • <script> jQuery(function($){ $("#no-reply-1084597 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>