array wordpress when get is null

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

Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?

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

Using OR relation in meta_query to check for a value before sorting by another

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

Display articles with a different template in the home page | Solved |

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

Trying to get all links in my posts

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() );