Site logo

Archived topic

Need Separate Page For Blog Post Category

6 replies · Started by Sean on August 6, 2018

Viewing posts 1–7 of 7

Hi,

I have a separate link and page for the blog posts categorised as "Real Brides", how do I edit this so that the "real brides" posts showing on the blog page are moved to the "Real Brides" page and also keep it like this for future posts?

Thanks,
Sean

Thanks Leo, I installed i'm not sure if it is the solution I require. The main issue I want to remove the "Real Brides" posts from the blog whilst keeping them on the "Real Brides" page/blog.

Hope that makes sense!

Hi,
if I'm getting you right you like to hide posts from the blog. I do this with a function (see below).

1.Find out the Category Id of "Real Brides" and add it to the function below where it says "ID HERE"(keep the -).
2.Add the function to your functions.php file (with child theme or plugin)
3.Save and refresh the browser page of the blog.

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

Hope that helps!

Thanks Stefan, all working now!

You're welcome! :-)

Thanks Stefan :)

This archived topic is closed to new replies.