WP Query with custom taxonomy
You have to use your object like this : while ( $query->have_posts() ) : $query->the_post();
You have to use your object like this : while ( $query->have_posts() ) : $query->the_post();
In the interest of closure and so someone in the future researching anything similar doesn’t get sidetracked by my posting here, it turned out to be our memcached. Once we hooked up to a new cache, the category issue disappeared.
Ok I found a solution by following the recommandation of s_ha_dum to use pre_gets_posts. All the following code goes to functions.php 1 Create a new rewrite rule function rewrite_clean() { // my CPTs $types = array(‘projects’, ‘works’); foreach($types as $type) { add_rewrite_rule(‘^’.$type.’/([^/]*)/?$’, ‘index.php?post_type=”.$type.”&term=$matches[1]’,’top’); } } add_action(‘init’, ‘rewrite_clean’); transform the following format ?post_type=projects&term=architecture to the following … Read more
$taxonomy = ‘training_cats’; $orderby = ‘name’; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; // 1 for yes, 0 for no $hierarchical = 0; // 1 for yes, 0 for no $title=””; $empty = 0; $args = array( ‘name’ => $taxonomy, ‘orderby’ => $orderby, ‘show_count’ => $show_count, ‘pad_counts’ => $pad_counts, … Read more
Você já usou Custom post type permalinks? Have you ever used custom post type permalink? Ex: example.org/post_type/taxonomy_name/term_slug
According to the Codex: taxonomy-{taxonomy}.php – If the taxonomy were sometax, WordPress would look for taxonomy-sometax.php What I do when using custom taxonomy/custom post types is exactly what you mentioned in the second sentence. Make a page template and a page in the back end. Choose the template you built as the template to use … Read more
I would do it this way: get all sub-categories (include empty, set up hierarchically) as array retrieve the depth of the array in PHP (this part is taken (but adapted) from here) Altogether, it’s the following code, which is bundled into a function, but could, of course, be used directly somewhere in a template file: … Read more
If you are passing the before parameter that you can simply add any class that you want. You then style that class in style.css. <?php if ( get_the_tag_list() ) { echo get_the_tag_list(‘<ul class=”tag-list”><li class=”tag-item”>’,'</li><li class=”tag-item”>’,'</li></ul>’); } ?>
Is this what you are looking for? $query = new wp_query($arr); $arr = array( ‘author__in’=> array(2,4,6), //Authors’s id’s you like to include ‘posts_per_page’ => ’12’, ‘paged’ => $paged, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => array ( $cat_ids ), ) ) );
First of all note that a post can have more than one category, also posts can have no category, what you’ll do in that cases? And what about post update? That said, if you look at the url when in edit.php and select a category by clicking on its name, you’ll notice that the only … Read more