Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom post type courses with a custom field level. I want to run a query (mysql or WP query) that runs through every course (post) and if the level is greater than 3, append a tag called higher to it.

How would I go about this please?

Many thanks

Tim

share|improve this question
add comment

1 Answer

Put code below to your functions.php

add_filter('pre_get_posts', 'query_post_type'); function query_post_type($query) { if(is_category() || is_tag()) { $post_type = get_query_var('post_type'); if($post_type) $post_type = $post_type; else $post_type = array('post','cpt'); // replace cpt to your custom post type $query->set('post_type',$post_type); return $query; } }

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.