Loop custom post type by taxonomy (Category)

Before the loop starts use query_posts. Available parameters are here. Something like this: global $wp_query; query_posts( array( ‘post_type’ => ‘mycustomname’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘mytaxonomyname’, ‘field’ => ‘slug’, ‘terms’ => array( ‘myterm1slug’, ‘myterm2slug’ ) ) ) ) );

Taxonomy Extra Meta [duplicate]

You should be able to do something like this: add_action(“manage_posts_custom_column”, “my_custom_columns”); add_filter(“manage_edit-[POSTTYPE]_columns”, “my_new_columns”); function my_new_columns($columns) { $columns = array( “image” => “Image” ); return $columns; } function my_custom_columns($column) { global $post; if (“ID” == $column) echo $post->ID; elseif (“image” == $column) echo ‘default_value’; } Then you should be able to use $tax_term->image to show it. … Read more

limiting characters shown in taxonomy descriptions

function trunc($phrase, $max_words, $after = null) { $phrase_array = explode(‘ ‘,$phrase); if(count($phrase_array) > $max_words && $max_words > 0) $phrase = implode(‘ ‘,array_slice($phrase_array, 0, $max_words)) . $after; return $phrase; } This function returns the input shortened if there are more words in it than $max_words. You use it like this: $string = “This is a sample … Read more

Can I use $query->set() (in a pre_get_posts() hook) with a custom taxonomy in WP 3?

For what it’s worth, I just gave up on the ‘__not_in’ approach and went with the following somewhat sneaky solution: //Create the exclusion rule $new_tax_query = array( array( ‘taxonomy’ => ‘x_category’, ‘field’ => ‘slug’, ‘terms’ => array(‘y-slug’), ‘operator’ => ‘NOT IN’, ) ); //If there is already a tax_query, ‘AND’ our new rule with the … Read more

How to limit posts to 1 from each term with tax_query?

<?php $categories = array(‘economy’,’the-constitution’,’monetary-policy’,’liberty’); foreach($categories as $category) { $args = array( ‘posts_per_page’ => 1, ‘category_name’ => $category, ‘tax_query’ => array( array( ‘taxonomy’ => ‘highlight’, ‘field’ => ‘slug’, ‘terms’ => array( ‘lead’,’featured’ ), ‘operator’ => ‘NOT IN’ ) ) ); $wpse42358_query = new WP_Query( $args ); while( $wpse42358_query->have_posts() ) : $wpse42358_query->the_post(); // write post stuff here … Read more

How to create a page that lists custom taxonomies with links?

Once you get $taxonomy you can perform further logic: $tax = get_taxonomy( $taxonomy ); if( isset( $tax->has_archive ) && $tax->has_archive == true ) { // do output. archive will be wordpress_url + $taxonomy->name ?> <p> <a href=”https://wordpress.stackexchange.com/questions/43340/<?php echo site_url( $taxonomy->name ); ?>”> <?php echo $tax->labels->name; ?> </a> </p> <?php } This is untested, but you … Read more

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