• Resolved majaxlt

    (@majaxlt)


    Hello,

    I found this code for elementor post widget (https://github.com/elementor/elementor/issues/5457):

    
    add_action( 'elementor/query/my_custom_filter', function( $query ) {
            // The author of the current post
    	$author_id = get_the_author_meta('ID');
    	$query->set( 'author', $author_id );
    } );
    

    I have a directory website so it’s perfect for me. I can show every listing owner’s posts on his listing page.

    However if listing owner has no posts yet, it just shows just heading “User’s articles” with blank space on his listing page.

    Can someone help me to add if statement for this code? Something like: If query is empty, echo “User has no articles yet”.

    Thank you!

    • This topic was modified 2 years, 6 months ago by t-p. Reason: Moved to Fixing WordPress from Developing with WordPress
    • This topic was modified 2 years, 6 months ago by James Huff.
    • This topic was modified 2 years, 6 months ago by James Huff.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Print out custom sentence if query results <1’ is closed to new replies.