How To Limit Hierarchical Pages Depth (For Custom Post Types) To Children Only
function my_test($a) { $a[‘depth’] = 1; return $a; } add_action(‘page_attributes_dropdown_pages_args’,’my_test’); Put that in a theme’s function.php or in a plugin.
function my_test($a) { $a[‘depth’] = 1; return $a; } add_action(‘page_attributes_dropdown_pages_args’,’my_test’); Put that in a theme’s function.php or in a plugin.
Found this way: if ( 0 == $post->post_parent ) { the_title(); } else { $parents = get_post_ancestors( $post->ID ); echo apply_filters( “the_title”, get_the_title( end ( $parents ) ) ); } Anyone got a better way please answer.
I’m not sure, if you already found a solution for this, but when I searched for a similar one yesterday, I found this tutorial on WPtuts very helpful. It uses radio buttons, but you can easily modify it to get it working with checkboxes as well. http://wp.tutsplus.com/tutorials/creative-coding/how-to-use-radio-buttons-with-taxonomies/
You could make a list of paths to check… $page_paths = array( ‘analysis/firstNamelastName’, ‘exercise/firstNamelastName’ ); Then check if there’s a page object for each of the page paths. foreach( $page_paths as $page_path ) { echo ‘<code>’ . $page_path . ‘</code> ‘ . PHP_EOL; if( ! $page = get_page_by_path( $page_path ) ){ echo ‘Does not exist.’ … Read more
And as it usually happens, I find the answer a few minutes after posting the question… So here’s what I did in my theme’s functions.php file to solve my problem: function modify_products() { if ( post_type_exists( ‘product’ ) ) { /* Give products hierarchy (for house plans) */ global $wp_post_types, $wp_rewrite; $wp_post_types[‘product’]->hierarchical = true; $args … Read more
There are probably some better ways to do this but you can always do a three simple foreach loops. I wrote an example function that does the job well and should serve you as a good starting point: function print_taxonomic_ranks( $terms=”” ){ // check input if ( empty( $terms ) || is_wp_error( $terms ) || … Read more
If you want to keep ‘authors’ as the base slug in the permalinks, i.e. example.com/authors/stephen-king/ for the ‘authors’ CPT, example.com/authors/stephen-king/the-shining/ for the ‘books’ CPT and example.com/authors/stephen-king/the-shining/chapter-3/ for the ‘chapters’ CPT, WordPress will think pretty much everything is an ‘authors’ post or a hierarchical child of an ‘authors’ post and, since that is not the case, … Read more
When Working with pages you can select a parent page and that value is saved as the parent page id number in the child page’s post_parent field in the database. In your case, you are using a custom post type so you would need to create your own metabox for the parent page; something like: … Read more
No core hacking needed — thanks to: HOOKS. Hooks allow to fix the issue with a nice combination of a filter replacing “–” by “, ” before output and an “if” block to make sure the output is not also filtered for the admin interface 🙂 and finally, saving all your tags with comma in … Read more
Thanks to Ivaylo for this code, which was based on Bainternet’s answer. The first function below, get_term_top_most_parent, accepts a term and taxonomy and returns the the term’s top-level parent (or the term itself, if it’s parentless); the second function (get_top_parents) works in the loop, and, given a taxonomy, returns an HTML list of the top-level … Read more