Archived topic
Showing featured posts in custom taxonomy archive page
9 replies · Started by Diego on October 4, 2021
Hi! I'm doing a lot of personalization on my site thanks to this forum, but I can't find anything for me about the archive pages.
I have a CTP that consists of evergreen articles for a "learn" section, separated from the blog.
I also have a couple of custom taxonomies for those posts. The archive pages for those taxonomies will have links to the posts and CTAs to different offers (related to that taxonomy).
So I'm trying to automate those archive pages.
I don't have a child theme yet, I'm using the "generate_do_template_part" filters and Elements/Hooks to achieve that, but I'm open to creating one if needed.
So I'm trying to make an archive page similar to this one, but adding CTA blocks (I found here in the forum a code to add those CTAs with the "generate_after_do_template_part" action):
https://www.brides.com/destinations-4691994
So what I'm stuck with right now is: how do I create a structure like that with 1 big featured post, then 3 columns of featured posts, and then 4 columns with the rest of the posts (the columns could vary, but just that concept)? The featuring of the post is just the post order.
I know that I could use WPSP and send params to it with the taxonomy to show. And I guess I can also create a custom content template, or even doing it with "generate_do_template_part" filter (that I guess would need a custom template too, but I can have it living inside a plugin, like all the changes I'm doing).
So, what would be the best course of action in your opinion?
I only half-understand the "generate_do_template_part" filters, tbh. Can't find the docs about it yet, but seems very powerful.
Thanks for your time.
Hi there,
i am getting a 403 forbidden on the URL provided, be good to see your current setup before i suggest something :)
Sorry for that, I didn't expect you to be so quick lol and push from my devel to staging, and I have issues with my internet connection so it's taking a while :/
I'll reply when it's live again.
No problems - let us know when we can view it :)
OK, the site is up now :)
So what I’m stuck with right now is: how do I create a structure like that with 1 big featured post, then 3 columns of featured posts, and then 4 columns with the rest of the posts (the columns could vary, but just that concept)? The featuring of the post is just the post order.
Assuming you don't intend to use pagination, you can place 3 WPSP list of the same query with this setup:
The first WPSP would only display 1 post. This post will be the "1 big featured post" like a sticky post.
The second WPSP would only display 3 posts in 3 columns. You then set an offset of 1 to this list so the post count offsets the 1 post on the first list.
The third WPSP would display the rest of the posts in 4 columns. You then set an offset of 4 to this list os the post count offsets the first and second WPSP listing.
Alternatively, we can just do this with just the default post loop and set the layout with CSS.
I believe we can do it with nth-child where we simply set 100% width for the first post (article:first-child), 33% for 2nd to 4th child and 25% to the rest of the posts. :D
Thanks for the answer. That was more or less my initial idea. But I was trying to be sure that it'd be the best way to do it.
Do you think that adding the WPSP in the code with a generate_do_template_part filter would be best? (I need to personalize it for every taxonomy term, so need to grab the term in PHP I think)
Thanks again
Couple of questions:
1. Will the posts layout require different backgrounds - as per the example site you linked to?
2. Will the CTA blocks have any relation to the posts below ( or above ) them ie. you require multiple loops that are displaying the posts related to the CTA?
Hey David, sorry, I missed the reply.
1. I would like to do that, yes, at least for the 3rd set of posts
2. Yes but no. I mean: the CTA blocks will be related to the taxonomy term, so in a sense, they'll be related to the posts. But all posts will be from the same taxonomy term (so I guess it's only a loop)
In that case the WPSP method would be the best route to go.
However, you don't want to use the generate_do_template_part filter. As this is used to display the post content, so every post would output your WPSP list and the other markup.
Instead you would remove the template and hook your content into generate_after_loop
Heres an example of that here where the user removed the default search results loop to add a custom search