How to query Posts from a custom post type which contains a custom taxonomy?

You have one or two issues here and possible future bugs that you might encounter term in your tax_query should be terms Be carefull with terms having dates as names and especially dates as slugs. This can cause issues and unexpected results if custom permalinks clash or if something falls into the template hierarchy for … Read more

Hide text if query has no posts

Remove line#5 and do the following: if ($query->have_posts()) : echo ‘<h2 class=”seccion col-sm-12″>Tour</h2>’; //we are showing the div inside the conditional I removed unnecessary <div>, as <h2> itself is a block element and can do the trick for you.

Custom Post Types,Permalink and Heirarchy

My problem was solved with this link. It was very helpful and difficult to find. function add_custom_query_var( $vars ){ $vars[] = “brand_name”; return $vars; } add_filter( ‘query_vars’, ‘add_custom_query_var’ ); function add_rewrite_rules($aRules) { $aNewRules = array(‘brand/([^/]+)/?$’ => ‘index.php?pagename=hotel&brand_name=$matches[1]’); $aRules = $aNewRules + $aRules; return $aRules; } add_filter(‘rewrite_rules_array’, ‘add_rewrite_rules’);

Default post_tag for custom post type

To set the taxonomy post_tag to your custom post type, you need to set the taxonomies parameter in your arguments when registering your post type taxonomies (array) (optional) An array of registered taxonomies like category or post_tag that will be used with this post type. This can be used in lieu of calling register_taxonomy_for_object_type() directly. … Read more

New post from database

With few lines of code you can transfer your data from your custom table to post table. Do some MySQL query using $wpdb Object to get data from your custom table. And then in foreach() loop use wp_insert_post and add_post_meta to add all those rows in your post table. And you are Done!

How to change single custom post template by custom taxonomy?

What you would do, is have your default single-article.php. This will get called by default because of the WP permalinks and templating system. At the top of your single-article.php do the following before your get_header() call: <?php $language = get_the_terms( get_the_ID(), ‘language’ ); if ( ! is_wp_error( $language) && $language && ‘French’ == $language[0]->name ) … Read more

Make a custom column sortable by a value from a different custom post type

(I was going to add this as a comment as it’s not a full answer, but I can’t yet…) I think you will need to use an SQL query as the standard meta_queries / orderby won’t work. Have a look at Custom Table Column Sortable by Taxonomy Query and http://wpdreamer.com/2014/04/how-to-make-your-wordpress-admin-columns-sortable/#sorting-posts-option-b for a couple of examples.

wp_editor for custom post type doesn’t save value

You forgot to declare the variable $main_detail. Since it’s a meta field you need to retrieve it first before you add it. $main_detail = get_post_meta($post->ID, ‘_main_detail’, true); Also, I can see that some errors in your code. echo ‘<label >’;?><?php _e( ‘short description:’ );?></label> Should be.. echo ‘<label >’ . _e( “short description:” ) . … Read more