Separate Posts and Custom Post Type in Custom Taxonomy archive template

Going from memory this should work for posts <?php $query1 = new WP_Query( array( “post_type” => “post”, “tag” => $term->slug) ); ?> The first query will only return posts that have been tagged [TEAMNAME] (as far as I can remember custom taxonomies can show up as tags on a post). This should work for teams … Read more

How to exclude products by tag from woocommerce shop page?

Add this to your functions.php function custom_pre_get_posts_query( $q ) { $tax_query = (array) $q->get( ‘tax_query’ ); $tax_query[] = array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘banana’ ), // Don’t display products with the tag “banana” ‘operator’ => ‘NOT IN’ ); $q->set( ‘tax_query’, $tax_query ); } add_action( ‘woocommerce_product_query’, ‘custom_pre_get_posts_query’ );

If specific user role then sticky post

It looks like it is possible. Sticky posts are stored as array of IDs in an option called ‘sticky_posts`, and you can modify options using hooks, so… There is a chance that something like this would work: function fake_sticky_posts_for_author() { $user = wp_get_current_user(); if ( get_current_user_id() && in_array(‘author’, $user->roles) ) { // Return the IDs … Read more

WP_Query meta_query results date by date

My idea is following. 1. Get the array of all meta dates your events have. DISTINCT in the MySQL query means do not include duplicates. <?php /* * From https://wordpress.stackexchange.com/a/9451/11761 */ function get_all_possible_meta_dates( $key = ‘event_dates_wp’, $type=”page”, $status=”publish” ) { global $wpdb; $result = $wpdb->get_col( $wpdb->prepare( ” SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm LEFT JOIN … Read more