Get term by custom term meta and taxonomy

Try This: $args = array( ‘hide_empty’ => false, // also retrieve terms which are not used yet ‘meta_query’ => array( array( ‘key’ => ‘feature-group’, ‘value’ => ‘kitchen’, ‘compare’ => ‘LIKE’ ) ), ‘taxonomy’ => ‘category’, ); $terms = get_terms( $args );

Front End Sorting Questions

orderby defaults to date, so we can always leave that out if we want to order by date. so the only thing we need to detect is if $_GET[‘sort’] is set and it’s equal to title. here we set the query args for all queries, and just add on the orderby if it’s title: $args … Read more

Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?

look for the string page/ and capture just the part of the url before it with strpos and substr: $url=”/players/type/pros/page/3/”; $find = ‘page/’; $trimmed_url = substr( $url, 0, strpos($url, $find) ); EDIT – so in the context of your question you could use: $url = $_SERVER[‘REQUEST_URI’]; $find = ‘page/’; $pos = strpos($url, $find); if($pos): $url … Read more

Order by meta_key in custom post type doesn’t affect the query

Please have a look in the WP_QUERY improvement and the WP_QUERY Order & Orderby Parameters. $args = array( ‘post_type’ => ‘event’, ‘post_status’ => ‘publish’, ‘orderby’ => array( ‘meta_key’ => ‘ASC’ ), ‘meta_query’ => array( array( ‘key’ => ‘_start_eventtimestamp’, ‘value’ => date(‘Ymd’), ‘compare’ => ‘>=’ ), ), ); Hope it will work for you!

Show one post per author and limit query to 8 posts

I believe that you can achieve this effect by grouping the query by author ID, which will require a filter(mostly cribbed from the Codex): function my_posts_groupby($groupby) { global $wpdb; $groupby = “{$wpdb->posts}.post_author”; return $groupby; } add_filter( ‘posts_groupby’, ‘my_posts_groupby’ ); If you have less than 8 authors, however, this won’t work. (You will get a number … Read more

Show single post then all posts (with pagination)

Pagination does not work well will with secondary queries. First, the ordinary pagination functions depend upon the main query in the global variable $wp_query. They won’t work with secondary queries. There are already a number of questions here about that if you search the site. Second, trying to paginate secondary queries tends to result in … Read more

Custom Field Query – Meta Value is Array

meta_query needs to be an array of arrays – have a look at the code sample in the Codex again. So, for your example: $args = array( ‘post_type’ => ‘pf_cookbook’, ‘meta_query’ => array( array( ‘key’ => ‘pf_cookbook_recipes’, ‘value’ => ‘5’, ‘compare’ => ‘NOT IN’, ‘type’ => ‘NUMERIC’ ) ) ); );

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