[Resolved] Blog categories, masonry layout

Home Forums Support [Resolved] Blog categories, masonry layout

Home Forums Support Blog categories, masonry layout

  • This topic has 9 replies, 3 voices, and was last updated 2 years ago by David.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2198950
    Paul

    so i have a page ‘insights’ for a blog, and set it to masonry layout in customization and set the ‘reading’ option to the insights page, and that works.
    however, on the insights page editing, i set all but one category on the categories option on the latest posts widget, and the masonry layout seems to ignore that setting and display all posts regardless of category. so that’s one issue.

    plus, i’d like to display the other category on a separate page with the masonry layout. is that possible? looks like maybe the blog generatepress layout items are only for a default blog of everything? i did notice though that if i go to the standard wordpress ../category/<special-category> it displays a header of <special-category> (which i don’t want) and the masonry of the category posts below.

    #2198958
    Fernando
    Customer Support

    Hi Paul,

    To have a better understanding of the issue, may you kindly provide the link to the site in question?

    You may use the private information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information

    Hope to hear from you soon. 🙂

    #2199427
    Paul

    here you go (in private).

    #2199454
    David
    Staff
    Customer Support

    Hi there,

    the Insights page is the the page you have set to Display your Latest Posts in Settings > Reading.
    When you apply that setting WordPress completely ignores anything you do in the page editor and instead displays the Blog Template of the Theme.

    OK so if i understand correctly you want to exclude a category from the Blog ( insights ) page? If so add this PHP Snippet your site:

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

    In that code you will see -66 which refers to the Category ID you want to exclude. To get that ID, go to Dashboard > Posts > Category and edit the Post Category you want to exclude, and check the URL in the Browser search field it will say the ID=XX something.

    #2199461
    Paul

    that’s great David, and worked. thank you.

    next challenge… so for the other page i want with the excluded category of posts shown, how do i get the nice generatepress masonry layout on that page?

    #2199663
    David
    Staff
    Customer Support

    As you mentioned above, you simply follow the https://yourdomain.com/category/cat-term URL and that will display the choosen cat-term eg. corporate with masonry.

    #2199671
    Paul

    2 issues:

    1) client wants a custom page url for that category (not /category/corporate)
    2) the category page shows a title which i don’t want.

    #2199693
    David
    Staff
    Customer Support

    1. Removing the Category base from the URL.
    Give this plugin a shot:

    https://wordpress.org/plugins/remove-category-url/

    2. Add this PHP Snippet to remove archive titles:

    add_action( 'after_setup_theme', function() {
        remove_action( 'generate_archive_title', 'generate_archive_title' );
    } );
    #2199710
    Paul

    you. are. awesome.

    thanks so much!

    #2199752
    David
    Staff
    Customer Support

    You’re welcome

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.