Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1014986

    Hello,

    I’new at this forum, and… I have a problem ;)

    The case:
    on my site there is a page with two masonry galleries: first one displays “featured news” category posts, and the second one – “news” category posts.
    Everything works fine as long as there is at least one post in each of displayed categories.
    But if there is no post in category “featured news”, then “first” masonry gallery (the one that should display “featured news”) displays ALL posts of ALL categories. Second masonry gallery (responsible for displaying “news” category posts) works fine.

    I’m running WP version 4.9.8 and Enfold 4.4.1.
    My site uses 35 (so far) categories of posts.

    HELP ! :)

    Regards,
    Grzegorz

    #1015098

    Hey Grzegorz,

    Thank you for using Enfold.

    Where can we see the issue? Please provide the site url and the login credentials in the private field. Do you have a page called “news”?

    Best regards,
    Ismael

    #1015186

    Hey Ismael,

    thank you for reply.
    Details in private field :)

    Best regards,
    Grzegorz

    #1015601

    Hi,

    That is the default behavior of the masonry element. If the selected term or category is empty or if it doesn’t contain any posts, the masonry element will display all posts from every terms or category. You should delete the element if you don’t have any posts for that category yet or you can add this code on the functions.php file.

    add_filter('avia_masonry_entries_query', 'avia_masonry_custom_query', 10, 2);
    function avia_masonry_custom_query( $query, $params ) {
        $args = array( 'posts_per_page' => 1, 'offset'=> 1, 'category' => $params['categories'] );
        $posts = get_posts( $args );
        if(!$posts) {
            $query = array();
        }
        return $query;
    } 
    

    Best regards,
    Ismael

    #1015700

    Thank you for reply.

    After two little modifications of your function it works as expected. I only had to change “1” to “0” :)

    Great support and great theme!

    Best regards,
    Grzegorz

    #1016062

    Hi Grzegorz,

    Glad you got it working for you! :)

    If you need further assistance please let us know.

    Best regards,
    Victoria

    #1016063

    Hi Grzegorz,

    Glad you got it working for you! :)

    If you need further assistance please let us know.

    Best regards,
    Victoria

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