Home › Forums › Weaver Xtreme Theme › Sorting posts – Link to Same Categories
- This topic has 17 replies, 3 voices, and was last updated 1 year, 3 months ago by
scrambler.
-
AuthorPosts
-
April 18, 2021 at 14:08 UTC - Views: 67 #68051
dosolutions
ParticipantIs it possible to sort the links (next – prev) in the Link to Same Categories option?
Thanks
April 18, 2021 at 16:04 UTC - Views: 65 #68052scrambler
ModeratorNot that I know of, this is a WordPress thing, you may want to search on WordPress.org in case there is a PHP method
April 18, 2021 at 16:32 UTC - Views: 63 #68053dosolutions
ParticipantThere are a couple, just searched for sort posts within categories.
Thanks for the tip.
-Daniel
April 18, 2021 at 17:10 UTC - Views: 64 #68054scrambler
Moderator@dosolutions Remember that if you change PHP files, you need to do that in a child theme.
And if it works, post back here how you did it, as this is a request that has come before
April 18, 2021 at 17:19 UTC - Views: 57 #68055dosolutions
ParticipantThe problem with the plugins i have found is that they only allow manual drag and drop sorting, not alpha sort.
It appears there is a way to do this in the category.php file;
<?php if (is_category()) { $posts = query_posts($query_string . ‘&orderby=title&order=asc’); } ?>
But I am not sure where to add this code or how might be best…
Alternatively in the functions.php
function foo_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', 'foo_modify_query_order' ); Again, without modifying the respective files, I am not sure how to proceed. -Daniel
April 19, 2021 at 03:04 UTC - Views: 50 #68057Weaver
KeymasterHave you tried the Page with Posts page template? I think if you specify a category to ahow, then the prev-next will link to the previous/next post in the category. And the sort options will work as weill.
April 20, 2021 at 02:26 UTC - Views: 44 #68075dosolutions
ParticipantThe page with post template? i that for posts or only pages?
Also the previous and next links do not show all posts in a category, and in fact show more posts in the next direction then in the previous direction. Is it possible that posts with multiple categories are some how exluded or other logic is at work to hide some posts?
Thanks
April 20, 2021 at 04:29 UTC - Views: 41 #68077scrambler
ModeratorWhat page are you starting from, a blog page, a single post page, and archive category page …..
April 20, 2021 at 12:17 UTC - Views: 41 #68078dosolutions
Participantrep-solutions dot com
The posts are included on pages in groups (by category) with a plugin called flex blocks.
Each post is an item, clicking on the item brings up that post. So it is “a page with posts” at first then just a single post.
The navigation on a single post is not consistent, in the next direction, there are more posts then in the previous direction, and the only thing i can think up is that any posts that have more than one category are somehow being excluded.
April 20, 2021 at 16:17 UTC - Views: 38 #68080scrambler
Moderatorthe home page does not have any post, you need to be specific.
But from what you are describing, you are speaking of previous – next post navigation form a single post page.
Once you are on a single post page, there is no way for the page to know that you want to navigate a single post category…..
April 21, 2021 at 04:05 UTC - Views: 36 #68084Weaver
KeymasterThere is a global setting for single page post views:
Single Page navigation links point to posts with same categories
This is on the Customizer -> Layout -> Post Specific , Post Navigation section
That is a global option, so once set, all Single Page views from posts of any category will have links to other posts in the same category. (I’m not sure what happens if a post is in multiple categories.)
This option has been in Weaver Xtreme for some time (free version), and frankly, I can’t remember every option. This one is probably not used that much.
April 21, 2021 at 04:30 UTC - Views: 27 #68085scrambler
ModeratorI never even knew about that one 🙂
I do remember people asking about it, so I guess at one point you must have decided to add the option
April 21, 2021 at 11:56 UTC - Views: 28 #68086dosolutions
ParticipantNav Links to Same Categories ↻ Single Page navigation links point to posts with same categories – is checked.
The problem is they are not alpha sorted, and there are fewer posts items than actually exist in the category! I think later issue is a bug.
-Daniel
April 21, 2021 at 11:57 UTC - Views: 25 #68087dosolutions
ParticipantSomething similar to this code link… may work, but i have no idea how to implement it.
wordpress dot org/support/topic/display-by-category-homephp-template/
April 21, 2021 at 15:53 UTC - Views: 23 #68088scrambler
ModeratorIt looks like your link describes a page with posts by category which the theme page with posts already does.
For the “Nav Links to Same Categories” issue can you elaborate /test on the following.
When you navigate from a single post page do you only get posts from the same category?
If you say yes but are missing some of them, can you confirm if these indeed have more than one category?
To verify, create a test post with just that category, and see if it gets included in the navigation.
Then create another test post and give it two category (including the one you are testing), and see if that gets included in the Navigation from a post in the testing category.
But I have tested with posts that have more than one category, and it works for me. SO you are going to need to look at what exactly is different on the posts that do not show up.
Eventually tell us what category is not fully working and give us a link to the the single post page of one of them, so we can test the navigation
As for sorting, I would assume the sorting is by date as this is the WP default, but check and confirm.
April 21, 2021 at 20:06 UTC - Views: 13 #68089Weaver
KeymasterI don’t know exactly what you are doing, but I’ve just done some substantial testing on my test site of the Nav Links to Same Categories option. It is working exactly as described and designed for me.
I have more than 100 posts, all with a category assigned, some with more that one category.
I can start with essentially any blog-like page that displays posts. I tried two different tests:
- I opened a any random post in Single view. If I then click next or previous post, the next or previous post (by date) with the same first category (if more than one category assigned) shown will be displayed. Continued previous/next clicking will show more posts with that same first category. The posts are displayed in date order – older on the previous, newer on the next.
- I open a show by category archive-like page which shows all the posts in a given category. Then opening any of those posts leads to the same results – previous/next single page displays of date ordered posts in the category.
This is the expected behavior. There are not options for showing in alphabetical order. There are no options for changing the date sorting of archive-like pages. I believe that sort order is settable for Page with Posts, but there is no way to change the archive-like pages.
-
AuthorPosts
- You must be logged in to reply to this topic.