-
AuthorPosts
-
January 5, 2021 at 1:37 pm #1270393
Hello all support team and happy Enfold new year :)
is it possible to leave the same related posts? every time a post is visited the related entries changed. is it possible that they do not change and always leave the same? to have a stable interlinking.
Thank you!!!
January 6, 2021 at 3:54 pm #1270645Hey Ganubis,
Thank you for the inquiry.
That is possible but you have to modify the includes > related-posts.php file. Look for this code around line 78..
array( 'tag__in' => $tag_ids, 'post_type' => get_post_type($this_id), 'showposts'=>$postcount, 'ignore_sticky_posts'=>1, 'orderby'=>'rand', 'post__not_in' => array($this_id)) );
.. and remove the orderby parameter. This should automatically fetch the posts based on the date they are published.
array( 'tag__in' => $tag_ids, 'post_type' => get_post_type($this_id), 'showposts'=>$postcount, 'ignore_sticky_posts'=>1, 'post__not_in' => array($this_id)) );
If you want to apply a different value to the orderby and order parameter, please check the following link.
// https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
Best regards,
IsmaelJanuary 8, 2021 at 12:42 am #1270969Thank you Ismael.
Work perfect.
And another related thing. Please:
Those images of the related post are square 180×180. but I use rectangular images of 833×435, is it possible that the images of the related posts were 345×180? or something to keep the aspect ratio?
Best regards
Anubis.January 11, 2021 at 6:00 am #1271485Hi,
Glad to know that it is working. :)
You could use the following plugin to adjust the default size of the thumbnails. The name of the thumbnail size used for the related entries is “square”.
// https://wordpress.org/plugins/simple-image-sizes/
The size can be changed in the Settings > Media panel and you have to regenerate or upload the images again afterwards.
Best regards,
IsmaelJanuary 13, 2021 at 1:36 am #1272000Hello,
I have followed all the steps, I have changed it to 345 × 180:
But for some reason the 180×180 square still shows:
Thank you very much for your help, Ismael.
A greeting.January 15, 2021 at 8:00 am #1272604Hi,
Thank you for following up.
Did you regenerate the images after adjusting the thumbnail size? You could also upload the images again manually, but regenerating the images is probably much faster and easier. The thumbnail regeneration option is in the same panel as the thumbnail adjustment options. But if you cannot find it in the same panel, try to install this plugin instead.
// https://wordpress.org/plugins/regenerate-thumbnails/
Best regards,
IsmaelJanuary 15, 2021 at 7:15 pm #1272808Hey,
Yes, the thumbnails are already regenerated at 345×180, and I’ve also seen them on the FTP.
But I don’t know why they keep showing square.
Now the code does call the 345×180 images correctly. But it shows them square and squashed.:
Best regards and thanks!!!
January 17, 2021 at 7:56 pm #1273154Hi Ismael
In the end I have succeeded, I added a new image size, regenerated the thumbnails, and I put this css:
#top .av-related-style-full .related_image_wrap, #top .av-related-style-full .related_image_wrap img { width: 115px !important; height: 60px !important; }
it worked but I would like to deactivate the plugin. Is it correct to put it in functions.php child the following code and then desactivate the plugin?
/* add related post new size*/ function ava_image_sizes() { add_image_size('related_post_mini', 115, 60, array('center', 'center')); }
is it correct? oO
thanks!!!- This reply was modified 3 years, 11 months ago by Astrobiologic.
January 18, 2021 at 4:30 am #1273201Hi,
Did you apply the new thumbnail size related_post_mini to the includes > related-posts.php template? The thumbnail should be specified in this code around line 113.
$post_thumb = get_the_post_thumbnail($related_post->ID, $image_size, array('title' => esc_attr(get_the_title($post_thumbnail_id))));
Replace $image_size with the new thumbnail.
$post_thumb = get_the_post_thumbnail($related_post->ID, "related_post_mini", array('title' => esc_attr(get_the_title($post_thumbnail_id))));
Best regards,
IsmaelJanuary 18, 2021 at 9:48 pm #1273484Hi.
Everything OK. +10
Thank you very much for all the help Ismael.
Best regards!!!!!
January 18, 2021 at 11:48 pm #1273507Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Static related post.’ is closed to new replies.