Using pre_get_posts for taxonomy post count

I answered my own question I just implemented it wrong when testing it on my end (mis-typed the taxonomy). This is correct: // Change the number of posts that show up on the taxonomy template function custom_tax_post_count ( $query ) { if (($query->is_tax(array(‘taxonomy_1’, ‘taxonomy_2’)) )) $query->set( ‘posts_per_page’, ‘-1’ ); } add_action( ‘pre_get_posts’, ‘custom_tax_post_count’ );

Display Slug instead of Name

From your code, it looks like product_cat is a custom taxonomy. get_the_terms returns an array you can get the slug from. For instance… $terms_array = get_the_terms($post->ID, ‘procuct_cat’); $term_slug = $terms_array[‘your index’]->slug;

Update permalinks when new category added to custom post type taxonomy

That’s not how custom taxonomies and post types work This is what you do: On the init hook, call register_custom_taxonomy or register_post_type If you change your calls to register_custom_taxonomy or register_post_type, or add new ones in your code, regenerate permalinks by visiting the permalinks settings page and clicking save You’re done So if I follow … Read more

Filter taxonomy admin pagination

The root problem, as you can see here, resides in the fact that WP counts items (terms) to paginate this way: ‘total_items’ => wp_count_terms( $this->screen->taxonomy, compact( ‘search’ ) ), Instead, it should count terms from the result of the query. I believe this is an issue and that it should be reported on WP bug … Read more

Automatically Updating Publish Date Bug

You could also hook into the save_{$post_type} action, which fires only when a certain post type is updated. This hook passes to post’s ID to the callback function: add_action( ‘save_post’, ‘my_callback_function’ ); function my_callback_function( $post_id ){ if ( ! wp_is_post_revision( $post_id ) ){ // Unhook this function so it doesn’t loop infinitely remove_action(‘save_post’, ‘my_callback_function’); // … Read more

How to display terms from a custom taxonomy in a hierarchy AND with custom html markup?

Solved it with the following Custom Walker: class CustomWalker extends Walker_Category { function start_el(&$output, $item, $depth=0, $args=array()) { $output .= “\n<li><a href=\”http://website.com/?ls=&location=” . $item->slug . “\”>”.esc_attr($item->name); } function end_el(&$output, $item, $depth=0, $args=array()) { $output .= “</li>\n”; } }

Avoid duplicate post from same Taxonomy

I see two ways to go about it, both quite similar. A) You can collect IDs of displayed posts in an array and then exclude those with post__not_in query parameter like so: $years_loop = get_terms( array( ‘taxonomy’ => ‘works_year’, ‘orderby’ => ‘slug’, ‘order’ => ‘DESC’, ) ); // array for displayed posts, we will update … Read more

Get taxonomy parent using child slug (from merged taxonomies)

Since in most cases I would need to now the ‘taxonomy’, one work around I found (actually, pointe by @Howdy_McGee) was to pass the slug of the term and it’s parent to the value, and then split-string. Here is my final code: foreach ($tax_categorias as $tax_categoria) { echo ‘<option value=”. $tax_categoria->slug .”.’. $tax_categoria->taxonomy .” . … Read more

Taxonomy linked to pages

Both your double and single quotes are not the correct kind in this block of code. Also, the taxonomy name is ‘colecciones’ with a small ‘c’, but you used ‘Coleccions’ with a capital ‘C’. The match is case sensitive. Thus your function code should be: function show_product_colecciones(){ $collections = wp_get_post_terms( get_the_ID(), ‘colecciones’ ); $collection = … Read more

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