M
M
miron-partner2018-08-03 11:36:43
WordPress
miron-partner, 2018-08-03 11:36:43

How to display posts from different categories in blocks on the tag (tag) page?

Hello. There is a site on Wordpress where material of various formats is published: articles, photos, videos, questions and answers, polls, etc. Each format is a category. All labels are common. I want the tag page (archive for the tag) to be formed not as usual - posts from all categories that have the desired tag in the order of publication date (most recent first), but for example, first a block with a list of articles, then a block with a list of photos, then a block with a list video and so on. And most importantly, in the first place, the block of the category from which the person went to the page of the tag archive should be displayed first.
How can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2018-08-03
@miron-partner

Hello!
I can tell you how it should be in theory....
1) You need an archive.php template (common for all categories, taxonomies, etc.), or better a tag.php template https://codex.wordpress.org /Tag_Templates
2) To understand where the user came from (from which category), you need to use PHP $_SERVER['HTTP_REFERER'] php.net/manual/en/reserved.variables.server.php
3) After you have defined the referrer, you can tag template, check with conditional tags and output, some block first, etc. https://codex.wordpress.org/Conditional_Tags
This is all in theory, in practice it is necessary to see, maybe there is a simple solution...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question