New answers tagged

3

Turns out meta_query was the way to go. This is the code I used to make it work. add_action( 'pre_get_posts', 'filter_posts' ); function filter_posts( $query ) { $now = date("Y-m-d H:i", strtotime('+2 hours')); if( is_category() && !is_admin() && $query->is_main_query() ) { $query->set( 'posts_per_page','10' ); ...


0

I think this might be part of the problem in your past query (the second one) array( 'key' => 'end_date', 'compare' => 'BETWEEN', 'type' => 'NUMERIC', 'value' => array($past, $now), ), You're using BETWEEN but I think something like < would be what you want. You don't ...


0

ok - so this isn't what I wanted but it does the trick. Adding a function to redirect when the user hits any term but one: function my_page_template_redirect() { if( is_singular( 'custom-post-type' ) && !(has_term('term', 'custom-taxonomy')) ) { wp_redirect( home_url(), 301 ); exit(); } } add_action( 'template_redirect', '...


0

Your setup makes no sense, you are querying, but not making any use of the query. Your parameters can easily be merged and used in one query unless you have to do something with the first one. Anyway, you can store the post ids from first query in an array and then take advantage of the parameter post__not_in parameter to remove posts returned by the first ...


0

Eventually I solved the problem. I displayed the actors in dynamic views element (from dynamic.ooo) on a frontend page. I put the filter criteria like so: filter by these conditions field = relatie_test (user based relationship field) operator = LIKE value = user(ID) That did the trick for me.


0

You should not use the query var API for that, use $_GET or filter_input instead. get_query_var is for accessing parameters on the main WP_Query, not for retrieving URL GET parameters. Using this API for URLs is misleading and can trigger lots of unexpected problems. The query variable API is for rewrite rules and WP_Query, e.g. for handling custom ...


Top 50 recent answers are included