- This topic has 5 replies, 3 voices, and was last updated 3 years, 5 months ago by
David.
-
AuthorPosts
-
November 10, 2022 at 2:13 pm #2410518
Julien
Dear GeneratePress team,
For the post navigation, I would like to make the following changes:
– I assume that posts are ordered by publishing date by default. Would it be possible to order them by post ID?
– In my posts, I have created an ACF field, and I would like to display it instead of the post title. Can it be done?Thank you in advance.
Kind regards,
Julien
November 10, 2022 at 6:32 pm #2410664Fernando Customer Support
Hi Julien,
The Post Navigation is a WordPress core Feature. By default, it’s ordered by date. It’s quite complicated to alter, and it’s also out of our scope of support. See here for what our support includes: https://generatepress.com/what-support-includes/
I found this thread however which may be insightful: https://wordpress.stackexchange.com/questions/73190/can-the-next-prev-post-links-be-ordered-by-menu-order-or-by-a-meta-key/73194#73194
It may be good to raise a topic here as well: https://wordpress.stackexchange.com/
With regards to replacing the Post Title with an ACF field value, it’s possible. You may use a GenerateBlock Headline Block added through a Block Element – Page Hero for instance.
References: https://docs.generatepress.com/article/block-element-page-hero/
https://docs.generateblocks.com/article/headline-overview/#dynamic-dataThe GB Headline Block can retrieve ACF text fields.
November 11, 2022 at 10:23 am #2411674Julien
Hi Fernando,
Thanks a lot for your quick feedback and details. I will check on Stack Exchange regarding how to order by ID.
Regarding the ACF field, sorry if I wasn’t clear enough. I would like to display this field in the post pagination and not on the article headline. By default, the loop is:
< “previous article title” “next article title” >And I would like to display the following navigation:
< “previous article ACF field” “next article ACF field” >There is any hook/filter to modify the pagination component?
Thanks in advance.
I wish you a great Friday.
Julien
November 13, 2022 at 4:51 am #2413454David
StaffCustomer SupportHi there,
sorry for delay, we missed your last reply.
There is the
generate_post_navigation_argsfilter:That can be used to modify the paging links.
Heres an example that outputs the featured image with the title:
https://generatepress.com/forums/topic/next-previous-post-based-within-category/page/2/#post-1451510
Note how we use:
$prevPost = get_previous_post(true);to get the ID using$prevPost->IDwhich you could use to get your ACF field.November 13, 2022 at 12:49 pm #2414058Julien
Hi David,
No worries, thanks a lot for your feedback.
Thanks to the information that you shared, I was able to achieve what I set out to do.
Kind regards,
Julien
November 14, 2022 at 2:06 am #2414488David
StaffCustomer SupportGlad to hear that!
-
AuthorPosts
- You must be logged in to reply to this topic.