Archived topic
Posts, and Post length, and filters
5 replies · Started by Sharon on August 1, 2019
1. I would like to have my post on the blog page show alphabetically by title. How do I do that?
2. I would like to put in a filter for only related blogs to show on the sidebar as opposed to recent posts. How do I do that?
3. When I add the sidebar, the text of my blog gets squeezed so there is too much white space other either side of the pages. I tried adjusting the container but it does spread out the text. How can I utilize more of the page so it there is less white space on the left side of my posts?
Thanks for your assistance
Hi there,
1. You can add this PHP snippet to order posts alphabetically:
function db_abc_modify_query_order( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'db_abc_modify_query_order' );
https://docs.generatepress.com/article/adding-php/
2. You would need to use a related posts plugin - this article provides some of the more common ones:
https://www.wpbeginner.com/plugins/5-best-related-posts-plugins-for-wordpress/
Something to be mindful of is that these plugins can add a lot overhead to your server, so can make your site run slower when you have a lot of posts.
3. Could you activate the sidebar so i can take a look at what the problem is?
Yes I have activate the side bar in the industries, here: https://nir-for-food.com/seafood/
Aah ok - that Site uses a Layout Element to narrow the width of the single post. Go to Appearance > Elements and look for the Layout assigned to the Posts. Edit that and go to the Content tab where you can change the container width.
This suggestions you offered work great. Thank you so much. It was just what I needed.
Glad to be of help