Using global $post; to get featured image for custom post via WP_Query

$port_query->the_post(); should set the $post global. That isn’t the problem. The problem is that the you are trying to use $post before your secondary Loop runs (99% sure). You’ve hooked the bkg_featured_image() function to wp_head. wp_head runs in the header of the document, which, unless you are careful, will run before the other template code. … Read more

How do I make a custom taxonomy for a CPT appear inbetween title and editor boxes?

In your case you can edit the following code to accomplish what you are looking for by assigning the custom taxonomy meta box to a custom context and then running do_meta_boxes /** * insert meta boxes before main editor below title */ function wpse_140900_add_meta_boxes_after_title( $post ){ // per the comment below filter by post type … Read more

get_the_terms return only last term

Instead of get_the_terms try using get_terms and set the hierarchal argument to true. Also make sure you show empty so you are not hiding your empty categories. Try something like this: $args = array( ‘hide_empty’ => false, ‘hierarchical’ => true ); $terms = get_terms(‘portfolio_pt’, $args); foreach($terms as $term) echo $term->name;

Insert HTML inside link in a walker

You can try to skip the CategoryThumbnailWalker and use instead the list_cats filter. Here’s an untested example: add_filter( ‘list_cats’, ‘wpse_149898_list_cats’, 99, 2 ); wp_list_categories(array( “child_of” => get_queried_object_id(), “depth” => 1, “hide_empty” => false, “hierarchical” => 1, “orderby” => “name”, “pad_counts” => 0, “post_type” => “projects”, “show_count” => 0, “show_option_none” => “”, “taxonomy” => “project-category”, “title_li” … Read more

Display multiple custom post types and sort them chronological by one of their fields

There is no output for this sample code because the IF statement you used will never return true, since the string ‘post_type’ will never be equal to any other string but ‘post_type’. Use get_post_type(): if ( get_post_type() == ‘eventtype1’ ) { To order by a date custom field, you will need to use the same … Read more