Look Through Family Tree and Find Featured Image

I don’t see anything particularly wrong with it, although I’d probably write the loop like this: $featuredImage=””; foreach ( $familyTree as $family_postid ) { if ( has_post_thumbnail( $family_postid ) ) { $featuredImage = get_the_post_thumbnail( $family_postid, ‘full’ ); break; } } A bit simpler to understand and eliminates the use of the counter and boolean found … Read more

How WordPress manages nested dropdown?

Actually <option> field doesn’t work with any CSS. So WordPress Developers/Designers did a simple yet nice trick for the nesting layout for <option> fields. Actually in your inspection you missed something there: <select name=”page_id” id=”page_id”> <option value=”1″ class=”level-0″>Level 0</option> <option value=”2″ class=”level-1″>&nbsp;&nbsp;&nbsp;Level 1</option> <option value=”3″ class=”level-1″>&nbsp;&nbsp;&nbsp;Level 1</option> <option value=”4″ class=”level-2″>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Level 2</option> <option value=”5″ class=”level-3″>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Level 3</option> … Read more

Display custom post type in hierarchical order with get_terms

Try something like this: <?php $parent_terms = get_terms( ‘name_of_your_taxonomy’, array( ‘parent’ => 0, ) ); foreach ( $parent_terms as $parent_term ) { $child_terms = get_terms( ‘name_of_your_taxonomy’ array( ‘child_of’ => $parent_term->term_id, ) ); foreach ( $child_terms as $child_term ) { $args = array( ‘post_type’ => ‘product’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘name_of_your_taxonomy’, ‘field’ => ‘slug’, … Read more

Twenty Fifteen: Adjacent posts by menu_order [duplicate]

EDIT According to the OP, this question/answers solved the issue ORIGINAL ANSWER the_post_navigation(), right down to its very core, uses get_adjacent_post() to return and display the next and previous post to the currently viewed post. By default, these adjacent posts are returned by post date. We can alter that by filtering the relevant ORDERBY clause … Read more

How to output hierarchical taxonomy path, with only the deepest term assigned?

Use get_the_terms to fetch the post’s term, then use get_ancestors to get an array of that term’s parent IDs. $tax = ‘category’; $terms = get_the_terms( get_the_ID(), $tax ); if( $terms && ! is_wp_error( $terms ) ){ // check for and output any ancestors $ancestors = array_reverse(get_ancestors( $terms[0]->term_id, $tax )); if( $ancestors ){ foreach( $ancestors as … Read more

Categories vs. Page Site Organization

You could create a customised ‘landing page’ using a template file? Creating category-internal.php with custom layout would display content at the /category/internal/ url. Here is some more info: https://codex.wordpress.org/Category_Templates http://www.wpbeginner.com/wp-themes/how-to-create-category-templates-in-wordpress/

Display hierarchical subterms of custom taxonomy based on depth

I love a good challenge! The function here: function get_post_categories_sorted ( $post_id ){ $terms = wp_get_post_terms( $post_id, ‘category’ ); $sorted_terms = []; foreach( $terms as $term ){ $depth = count( get_ancestors( $term->term_id, ‘category’ ) ); if( ! array_key_exists( $depth, $sorted_terms ) ){ $sorted_terms[$depth] = []; } $sorted_terms[$depth][] = $term; } return $sorted_terms; } will give … Read more

Hierarchical Custom Post Types – Show only parent on tax archive?

Figured a simple pre_get_posts would do the trick, It will, you just need to query posts that have a parent of 0. Assuming your taxonomy slug/name is literally just region: function wpse_286405_parents_only( $query ) { if ( ! is_admin() && $query->is_tax( ‘region’ ) ) { $query->set( ‘post_parent’, 0 ); } } add_action( ‘pre_get_posts’, ‘wpse_286405_parents_only’ );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)