• Resolved yoyokhan

    (@yoyokhan)


    I am using otter post block to show post in a grid. There is no option to sort posts as per modified date or updated status. Can you please provide some code to do so for a post block?

    thanks for your time

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support AndreeaR

    (@andreearadacina21)

    Hi @yoyokhan,

    Thank you for using Otter!

    You can control the post date under Elements > Meta > Display Post Date > Display Last Updated Date – https://vertis.d.pr/i/qOVFAQ.

    Then, under Settings > Order By, select one of the options, e.g., Newest to Oldest – https://vertis.d.pr/i/aHQBLu.

    Let me know if you need anything else!

    Plugin Author Hardeep Asrani

    (@hardeepasrani)

    Hey @yoyokhan,

    You can use this snippet to replace order to be modified instead of date:

    add_filter( 'themeisle_gutenberg_posts_block_query', function( $args, $attributes ) {
    	$args['orderby'] = 'modified';
    	return $args;
    }, 10, 2 );

    You can also use attributes to filter by id if you only want to do it for a particular block and not all posts block used on the website.

    Thread Starter yoyokhan

    (@yoyokhan)

    Thanks a lot. It worked.

    Thread Starter yoyokhan

    (@yoyokhan)

    @hardeepasrani Can you tell me how to use attributes to use it for a specific block only. Currently it sorts all posts as per modified date.

    Regards

    Plugin Author Hardeep Asrani

    (@hardeepasrani)

    If you check your block in HTML mode, you will see it has an ID assigned to it. You will recognize it with the format wp-block-themeisle-blocks-posts-grid-

    So using that value, you can run a if check before assigning the param:

    if ( 'your_id' === $attributes['id'] ) {
        $args['orderby'] = 'modified';
    }
    Thread Starter yoyokhan

    (@yoyokhan)

    @hardeepasrani Its not working. Am I using it right ?

    add_filter( 'themeisle_gutenberg_posts_block_query', function( $args, $attributes ) {
    	if ( 'wp-block-themeisle-blocks-posts-grid-XXXXXXX' === $attributes['id'] ) {
        $args['orderby'] = 'modified';
    }
    	return $args;
    }, 10, 2 );
    • This reply was modified 1 year ago by yoyokhan.
    Plugin Author Hardeep Asrani

    (@hardeepasrani)

    @yoyokhan can you send link to the page where you’ve this block added?

    Thread Starter yoyokhan

    (@yoyokhan)

    Its homepage and want to use it for 1st block only (Trending Posts)

    Plugin Author Hardeep Asrani

    (@hardeepasrani)

    You should be able to use it like:

    add_filter( 'themeisle_gutenberg_posts_block_query', function( $args, $attributes ) {
    	if ( 'wp-block-themeisle-blocks-posts-grid-94bbf9e5' === $attributes['id'] ) {
        $args['orderby'] = 'modified';
    }
    	return $args;
    }, 10, 2 );

    Let us know if it works.

    Thread Starter yoyokhan

    (@yoyokhan)

    Hi, thanks for your time and response. Its working

    Thanks for your help

    • This reply was modified 12 months ago by yoyokhan.
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Sort Posts as per modified Date’ is closed to new replies.