4

For my custom post type,i had set the 'hierarchical' to true for my url to be like http://example.com/custom/parent/child/.But there is this part in the WordPress codex.

Note: this parameter was planned for Pages. Be careful, when choosing it for your custom post type - if you are planning to have many entries (say - over 100), you will run into memory issue. With this parameter set to true WordPress will fetch all entries of that particular post type, together with all meta data, on each administration page load for your post type.

Does this means that its better not to set it to true,if i will have a lot of child pages? And if I don't use the hierarchical, how could I make the URL to be like the one above?

  • 1
    I's not aware about this issue. I'm just trying to make my voice out, so that someone can justify whether I'm in right direction, or not. May be a hierarchical Custom Taxonomy is the solution? You can have the same URL structure as of CPT. But we have to wait for WordPress 4.4 for adding Taxonomy Meta in right way. – Mayeenul Islam Dec 3 '15 at 9:43
  • @Mayeenul Islam Erm..ask a stupid question..is taxonomy meta means that the information about the categories and tag?what is it used for? – vid Proli Dec 3 '15 at 14:19
  • 1
    :) to me no question is wrong or stupid. Custom Fields are Posts'/Pages' meta fields, saved in postmeta. Taxonomy doesn't support any custom fields. WP 4.4 is making a taxmeta table for us with utility functions, so that we can save additional data with the taxonomy term. If 'class' is the taxonomy, I, IV, IX are the taxonomy terms (classes), and a flower denoting each class is the additional information to a taxonomy term, i.e. waterlily for class V is the term meta data. – Mayeenul Islam Dec 3 '15 at 15:37
  • @Mayeenul Islam Thank u so much for ur time and explanation :D This problem have bother me for quite a long time and finally i know what should i use to achieve this. – vid Proli Dec 3 '15 at 17:00
1

....if you are planning to have many entries (say - over 100), you will run into memory issue

Any hierarchical post type (even the build-in post type page) have this issue where a large amount of posts created have a huge impact on performance. This issue is experienced in the back end, and not in the front end. Having too much posts can lead to your back end page timing out, triggering a fatal error which leads to the dreaded WSOD. I have explained everything in my answer here, so be sure to check it out.

So in short, you can use a hierarchical post type for your project, but you need to be very sure that you will not have a lot of posts.

You can make use of a non hierarchical post type (like the build-in type post) with a hierarchical taxonomy like the build in taxonomy category. This way you make use of the parent/child relationship between terms. What will be an issue though is to create the URL structure you are after. This will definitely require custom rewrite rules.

One way or the other you are going to have issues, some of them will be easy to solve, others might be a bit more challenging. You will definitely need to go and work on a plan and make sure you have everything in place before you dive into the deep end. Once you are in the deep water, there is basically no turning back

  • Which/what type of function do i need to use to achieve example.com/custom/parent/child with a hierarchical taxonomy?Or do u know any guide/tutorial about this?Or how should i search for it? – vid Proli Dec 3 '15 at 17:49
  • 2
    You will need to play around with rewrite rules when registering your custom post type and taxonomy. Rewrites are not my strenght, but you can use plugins like Monkeyman Rewrite Analyzer to help you with rewrites to test your structures – Pieter Goosen Dec 3 '15 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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