how to automatically generate hierarchical menus from hierarchy of pages?
The wp_list_pages() function will generate a hierarchical list of pages for you.
The wp_list_pages() function will generate a hierarchical list of pages for you.
Yoast does have a filter for you to use. See here: https://gist.github.com/jmcclellan/b2d97ffee0e924e28fa1 I used this to add “parent” pages to custom post types. We wanted to use pages as our category landers w/ custom post types as children. Yoast would not output the parent page slug by default since there is technically no real relationship, … Read more
Update Mtekk’s answer does basically what I was suggesting w/o the need to touch the plugin itself, so my answer is of quite theoretical nature. He describes how to do that easily. I think the easiest thing for doing so as you’re mainly confident with the plugin (saying something minor to change), it would be … Read more
Using your method, I’ve edited it a bit to make it more viable. Here’s the code, below I’ll explain. <ul> <li><a href=”https://wordpress.stackexchange.com/questions/149424/<?php echo home_url(); ?>/projects”>Projects</a></li> <?php $term = get_term_by(“slug”, get_query_var(“term”), get_query_var(“taxonomy”) ); $tmpTerm = $term; $tmpCrumbs = array(); while ($tmpTerm->parent > 0){ $tmpTerm = get_term($tmpTerm->parent, get_query_var(“taxonomy”)); $crumb = ‘<li><a href=”‘ . get_term_link($tmpTerm, get_query_var(‘taxonomy’)) . ‘”>’ … Read more
You should change this line: echo “post_parent).”\”>”.get_the_title($post->post_parent) . “”; To something like this: echo ‘<a href=”‘. get_permalink($post->post_parent).'”>’. apply_filters(‘the_title’, get_the_title($post->post_parent)) .'</a>’;
You’ll want get_queried_object(). This is a very generic function – and simply returns the queried object- so a single post, this would be a post object. For instance, the return object may be of the form: Object ( [term_id] => 299 [name] => test [slug] => test [term_group] => 0 [term_taxonomy_id] => 317 [taxonomy] => … Read more
The issue with most breadcrumb functions is that it relies on the $post object on all pages. Not only is the $post global totally unreliable (see my post here), it might not even contain the data that we need, even if the $post global is not compromised The $post global on archive pages (which includes … Read more
It seems that you have a misunderstanding about a static front page and a blogpage and the returned result from the conditional tags. Here is a short explanation STATIC FRONT PAGE The general misconception is that your static front page is your home page, which it is not. The static front page is just a … Read more
You can use get_ancestors: <?php if ( $term_ids = get_ancestors( get_queried_object_id(), ‘category’, ‘taxonomy’ ) ) { $crumbs = []; foreach ( $term_ids as $term_id ) { $term = get_term( $term_id, ‘category’ ); if ( $term && ! is_wp_error( $term ) ) { $crumbs[] = sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/225528/%s”>%s</a>’, esc_url( get_term_link( $term ) ), esc_html( $term->name ) … Read more
Ok, problem solved. I´ll add the script below. Hope it´s useful for someone. if ( is_page() ) { $post = $wp_query->get_queried_object(); if ( $post->post_parent == 0 ){ echo “<li> » “.ucwords(str_replace(“-“, ” “, $post->post_name)).”</li>”; } else { $title = the_title(”,”, FALSE); $ancestors = array_reverse( get_post_ancestors( $post->ID ) ); array_push($ancestors, $post->ID); foreach ( $ancestors as $ancestor … Read more