WordPress sorting posts by date and title using a dropdown

Here I put orderby attributes as option values – date and title. <form method=”GET”> <select name=”orderby” id=”orderby”> <option value=”date”>Newest to Oldest</option> <option value=”title”>Alphabetical</option> <button type=”submit”>Apply</button> <form> On the same page you can recieve select value and set as orderby attribute $wpb_all_query = new WP_Query(array( ‘post_type’=>’post’, ‘posts_per_page’=>-1, ‘order’=>’ASC’, ‘orderby’=> esc_attr($_GET[‘orderby’]) ); Use your loop to show … Read more

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

Display WordPress archive template page in 3 columns and not 1 column [closed]

Without knowing the structure, class names, ids etc. it would be impossible to give you an answer that would help. But lets say that the structure is ul>li*6 <ul> <li>…</li> <li>…</li> <li>…</li> <li>…</li> <li>…</li> <li>…</li> </ul> The must basic of css that would create such a design would be ul { display: grid; grid-template-columns: repeat(3, … Read more

display condition based on post term and status

You are populating the $term variable with a multidimensional array, but type-and-value checking it (===) against a string. Second, you say terms are ‘des_1’ and ‘des_1’ (with underscore), but are checking for ‘des-1’ (with dash). wp_get_post_terms will return an array of term objects, so you should might be better of with has_term() for checking if … Read more