Check if almost 10 year old – working code is up to date
Check if almost 10 year old – working code is up to date
Check if almost 10 year old – working code is up to date
Try this global $wpdb; $sql = “SELECT display_name FROM “.$wpdb->prefix.”users WHERE id IN (SELECT user_id from “.$wpdb->prefix.”usermeta where meta_value LIKE ‘%agent%’)”; $result = $wpdb->get_results($sql);
Reading URL Parameters
One option is to use PHP function empty() and the AND / && operator to build your if check to be certain that all of the required parameters are present. if ( ! empty( $type_search ) && ! empty( $area_search ) && ! empty( $prezzo_search ) && ) { // your ocde } P.s. type … Read more
Cannot get sql request from Query object?
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. … Read more
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’, ‘my_page_template_redirect’ ); Answer based on this one: Disable … Read more
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 want to show events that have ended between … Read more
I haven’t tested this, but it looks like you just need to set an iteration variable (usually abbreviated $i), like this: <?php $i = 0; // This sets your variable $query = [ ‘post_type’ => ‘post’, ‘posts_per_page’ => 5 ]; $query = new WP_Query($query); while ($query->have_posts()) : { $query->the_post(); if($i == 0) : get_template_part(‘loops/acc-cards’); else() … Read more
After further investigation, I noticed my theme was actually replacing all the anchor tags with shortcodes for SEO purposes, so there weren’t any links in the content anymore. I was able to make it work by replacing $content = get_the_content(); with $content = apply_filters( ‘the_content’, get_the_content() );