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!
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.
@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
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';
}
@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.
@yoyokhan can you send link to the page where you’ve this block added?
Its homepage and want to use it for 1st block only (Trending Posts)
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.
Hi, thanks for your time and response. Its working
Thanks for your help
-
This reply was modified 1 year ago by yoyokhan.