Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot sort the posts by different categories #519

Open
jameslyf opened this issue Sep 11, 2024 · 1 comment
Open

Cannot sort the posts by different categories #519

jameslyf opened this issue Sep 11, 2024 · 1 comment

Comments

@jameslyf
Copy link

jameslyf commented Sep 11, 2024

Feature Request

Let's say the posts are within one same category but also fall in other categories. I want to list the posts with the same category ID=1 but also want to sort them by other categories. It seems I cannot make it work with "orderby" parameter. So I tried the following but it didn't work either:

[catlist id="1+2, 1+3, 1+4" pagination="yes" numberposts="20"]

I actually want to list all the posts within category ID "1" but sort them in the order of category ID "2, 3, 4". If the short code above works, that would help. I would like to know if there is any way I can achieve the result above? Thanks!

The only way it works is that I have to use 3 separated short codes to produce the result

[catlist id="1+2" pagination="yes" numberposts="20"]
[catlist id="1+3" pagination="yes" numberposts="20"]
[catlist id="1+4" pagination="yes" numberposts="20"]

However, it will produce an empty line between and also the pagination is not that useful at all in this situation.

My WP version is 6.4.5, and LCP plugin version 0.89.8

@klemens-st
Copy link
Collaborator

The plugin does not support such custom sorting at the moment, but there is a workaround you can implement.

  1. Add a custom field to each post you want to sort, e.g. order_group, and assing a numeric value that corresponds with the desired order of the post
  2. Add customfield_orderby parameters to your shortcode, it should look something like this: [catlist id="2,3,4" pagination="yes" numberposts="20" customfield_orderby="order_group" customfield_orderby_type=NUMERIC]

Now, if

  • all posts from cat id 2 have order_group=3
  • all posts from cat id 4 have order_group=2
  • all posts from cat id 2 have order group=1

in the resulting list you will have posts from cat 2 first, then cat 4, then cat 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants