Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #910925

    themer
    Participant

    Hey guys,

    I think this may be achievable in different ways, but I got a bit lost in options.

    What I want to achieve:
    Create a blog page that will only show certain posts (posts that I consider are “blog material”) that will use wordpress’ default URL for blogs: domain.com/blog

    Solutions I thought of:

    1) Idea: Create a regular page, and use Cornerstone’s Post lists using a tag (e.g. blog) as filter.
    Problem: Not sure if this will work and, if it does, can it be a long term solution that would streamline with wordpress functionality?

    2) Idea: Use a the tag “blog” to differentiate these blog posts, and then set the tag’s archive page as the default wordpress’ “Posts Page” (under Settings -> Reading -> Use static page)
    Problem: I don’t know how to do this, or if it’s even possible.

    3) Idea: Use a the tag “blog” to differentiate these blog posts, and then just link to it from the main menu.
    Problem: the URL would show as domain.com/tag/blog (as opposed to domain.com/blog )

    Any genius out there that can solve this one out?

    Thank you very much in advance! 🙂

    Regards

    #911377

    Rahul
    Moderator

    Hi @themer,

    Thanks for writing in!

    There’s a simple solution to what you want to achieve :

    1. Create a new page named “blog”
    2. Set it as a blog page from Settings > reading
    3. Add a new category and include those blog posts which you think are blog material into that category.
    4. Use “Recent posts” element from cornerstone and use that category to be displayed from it.

    Let me us know for any further help.

    Thanks

    #911382

    themer
    Participant

    Hello Rahul.

    That would be option 1.

    Te question is. Would that be a safe option in the long term? And will it function just as the theme’s archives and posts lists work (pagination, etc) for hundreds of posts? Or will it have a limit?

    Thank you!

    #911421

    themer
    Participant

    I just tried it. And it only allows the last 4 posts to show…

    #911929

    Nabeel A
    Moderator

    Hi there,

    You can use Offset option to select the initial offset of posts, for example:

    [recent_posts count="2" orientation="horizontal"] [recent_posts count="2" orientation="horizontal" offset="2"]

    Hope this helps!

    #912328

    themer
    Participant

    That still does not create an archive page type for certain blog posts. It does not display all posts (if hundreds) in a paginated fashion. Just like the normal post list, or any archive page.

    Or am I missing something?

    Thank you for your patience 🙂

    #912670

    Lely
    Moderator

    Hello There,

    Yes, since it is still a page, it will not work as archive with pagination.
    The easiest solution would be to create post category. Let say Category1, Category2, Category3. All of your post should be assign to specific post category. If you wanted to display only those post under Category1, we will add some code to exclude Category2 and Category3.

    Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    Then on your child theme’s functions.php file add the following:

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

    On this line $query->set( 'cat', '-8,-1' ); > change 8 and 1 to your Category2 and Category3 category ID. Negative sign before the number means that we will exclude those specific category from the query. So it is required that all post must include to those specific categories.

    Hope this helps.

    #914262

    themer
    Participant

    Applause!

    Awesome Lely! Thank you!! That was exactly what I needed! 🙂

    Since I have lots of categories, I searched for a way to do it they other way around (to only include one category in the blog). An this is how you do it (just in case anyone else is reading):

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

    Where it says 11, you enter the code for the category or categories you want.

    Here’s the site where I found the explanation: https://premium.wpmudev.org/blog/one-category-wordpress-homepage/

    Thank you very much Lely for the solution, and everyone for your time and effort.

    All the best.

    #917038

    Joao
    Moderator

    Thanks for your feedback and input 🙂