How to Create Hierarchical Directory for Nation Wide Mental Health Services

First of all, in WordPress here the best option to solve my problem is using Custom Post Types and Custom Taxonomies. To do that, I’ve created a file named “my_custom_posts.php” and put it inside the theme’s root folder. Then I’ve included this file in my “functions.php” using require(‘my_custom_posts.php’); You can also put your custom post … Read more

Get parent page/menu id of current post

I believe you want get_queried_object. If you have set your static front page and blog page from wp-admin->Settings->Reading then get_queried_object will give you information about the page you chose rather than about the posts in the Loop. Be aware that get_queried_object will return very different types of information depending on the kind of page you … Read more

How to include parent terms in hierarchical taxonomy URLs?

Just clarifying, what was pointed out by Parst with a working example of a custom taxonomy registration code: $labels = array( ‘name’ => _x( ‘Issue numbers’, ‘taxonomy general name’, ‘sascha_setup_post_type’ ), ‘singular_name’ => _x( ‘Issue number’, ‘taxonomy singular name’, ‘sascha_setup_post_type’ ), ‘search_items’ => __( ‘Search issues’, ‘sascha_setup_post_type’ ), ‘all_items’ => __( ‘All issue numbers’, ‘sascha_setup_post_type’ … Read more

Permalinks for WooCommerce Categories and Subcategories

I was able to resolve this with the following code which generates rewrite_rules for each subcategory, which is preferred during matching since it’s more specific: function wpse_291143_generate_taxonomy_rewrite_rules( $wp_rewrite ) { global $wp_rewrite; $base = “shop”; $rules = array(); $terms = get_terms( array( ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => false )); foreach($terms as $term) { $term_children = … Read more

How to show only parents subpages of current page item in vertical menu?

Finally, I solved it myself. Here is the solution: In functions.php: function show_all_children($parent_id, $post_id, $current_level) { $top_parents = array(); $top_parents = get_post_ancestors($post_id); $top_parents[] = $post_id; $children = get_posts( array( ‘post_type’ => ‘page’ , ‘posts_per_page’ => -1 , ‘post_parent’ => $parent_id , ‘order_by’ => ‘title’ , ‘order’ => ‘ASC’ )); if (empty($children)) return; echo ‘<ul class=”children … Read more

How to fix a double slash in custom permalinks with hierarchical taxonomy’s?

There is a quick and somewhat dirty potential solution to this. I say ‘potential’ because I can’t spot the problem by looking at the code. I only have my suspicions. Instead of passing a separator like that. Try trailingslashit. } else $chain .= trailingslashit($name); return $chain; I am guessing at where the problem is based … Read more