1

I want to make a tourism information website for my country. I want to make a structure like a tree.Tree structure showing hierarchy

Each block(node?) in the tree contains a description and image/s of the state/city/landmark. Further it must also contain links/some way to navigate to all its children as well as its parent. So the page for City 1 would look something like this.Sample page for City 1

The description and picture will obviously have to be added manually for each and every state/ city/ landmark. But the links forwards and backwards should be generated by some kind of code. Since doing that manually will not only be cumbersome but also very likely to introduce mistakes as the tree will grow laterally i.e. the number of levels will be the same but the number of states,cities and landmarks will balloon.

Now I figured I could do this by using tags and shortcodes. Another way would be to put the code in the page template. But then I would probably have to make single use templates for each post.

So I was wondering if that is the only/best way to do this? It seems to me this kind of thing should be pretty common and there ought to be a better way to do it but I cant quite find any info.

So my questions are these,

1- Is doing it by shortcodes a good way to go?

2- If I put the code in the page template, is there a way a single template may be used for all posts. That is, can the page template decide which filters to use for the list of posts based on the content or tags of the current post. e.g. for City 1 it needs to display Landmark A & B and State 1, but for City 2 it should display Landmark C & D and State 1. Which means it should be using different tags to filter through the posts.

3- Is there some other method or platform out there that would be better suited to my needs. I am a newcomer to wordpress, so I wouldn't mind switching to something else, I face a learning curve both ways.

Update: To rephrase my question. I want to know if there is a way to establish the parent child relations of the tree among my posts (each node in the tree is a post). And then use these relations to automatically display the desired content, that is within each post, display only links to its immediate parent and immediate children. I say automatically, because whenever I add a new post I dont want to go and edit its parent. It should automatically appear in the parent post, when I set it as a child of that post.

2
  • It is a very detailed but in the end it is a poor question. The answer to all questions of "Is it possible..." type is usually "yes". As it is the question is too abstract and less likely to get a useful answer Jan 2, 2017 at 7:50
  • @MarkKaplun, I agree with you. I gave this question +one, just because I recognized the effort brother Adil put in the question.
    – prosti
    Jan 2, 2017 at 8:16

1 Answer 1

1

1- Is doing it by shortcodes a good way to go?

Shortcodes! Why would you use shortcodes. You may have read about the WordPress before and this is great! But please provide the idea why?

2- If I put the code in the page template, is there a way a single template may be used for all posts. That is, can the page template decide which filters to use for the list of posts based on the content or tags of the current post. e.g. for City 1 it needs to display Landmark A & B and State 1, but for City 2 it should display Landmark C & D and State 1. Which means it should be using different tags to filter through the posts.

As I see this you need to have a CPT (custom post type) that you can call city. And you may use the Custom Taxonomy for the state. If not custom taxonomy you may use category to designate the state. If not both of these you may use the meta key for the state also. No problem.

3- Is there some other method or platform out there that would be better suited to my needs. I am a newcomer to WordPress, so I wouldn't mind switching to something else, I face a learning curve both ways.

Ah, you asked a blacksmith if there is a better blacksmith. This is not a smart question.

enter image description here


You need to read about the post meta information, and featured images. The drawing I tried to optimize for the lazy people, so you create te minimum WordPress code to achieve that.


Please describe the landmark also we may need to improve the structure.

5
  • I would use shortcodes to generate the list of links to the children of the node. For example landmark A and Landmark B would have the tags [city1(id 46), landmark (id 48)]. I would write the following shortcode in the content of my post on City 1: [su_posts taxonomy="post_tag" tax_term="46,48" tax_operator="2" order="asc" orderby="title"] And this should display a list of all posts with these tags. This way when I am creating a new landmark, e.g. Landmark E under City 1. All I have to do is assign it the tags and it will automatically appear in City 1, without the need for modifying City 1. Jan 2, 2017 at 6:37
  • To answer your othe question, Landmarks are the same as Cities and States. In fact all nodes in the tree are the same. They contain a description + image + Links to parents/children if any. Jan 2, 2017 at 6:39
  • I've looked at CPT, sorry but I don't see how that'll help. Could your shed some more light on the matter? And just to be clear I'll rephrase my question. I want to know if there is a way to establish the parent child relations of the tree among my posts (each node in the tree is a post). And then use these relations to display the desired content, that is within each post, display only links to its immediate parent and immediate children. The descriptions and images are not a problem. Its just the links to parent and children that I need to figure out. Jan 2, 2017 at 7:20
  • I think that you are in the right place to ask questions. Better to ask in here than on SO website for sure, if you plan to get the WordPress feedback. However, hard time for you know @AdilMasoudQureshi, you need to decide your design, and I would advise you ask more specific questions, just like Mark noticed.
    – prosti
    Jan 2, 2017 at 8:19
  • @AdilMasoudQureshi, note the design is something where you should not hurry. You may also ✓ my answer if you find it helpful. You can always ask another question.
    – prosti
    Jan 2, 2017 at 8:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.