Adding Category in WP_Query Not Working
Adding Category in WP_Query Not Working
Adding Category in WP_Query Not Working
Problem Fixed! there was an issue in input of post_meta_field. after updating post, problem fixed.
Very simply use get_post()… $my_post = get_post( $account->ID );
So I found the solution after tons of searching from the events calendar’s website and modified it to suit my needs. The code is as shown below: (Note I also removed the array to string conversion since it’s pretty pointless.) <?php // Support for multiple locations to be filtered. $request_cities = array_map(function($item){return utf8_decode(urldecode($item));}, explode(‘+’, $_REQUEST[‘city’])); … Read more
The problem is your $contenu variable. Try: $contenu .= ‘<div class=”effect-jazz”>’.get_the_post_thumbnail().'<div class=”jazz-try”> <div class=”h3″><a href=”‘.get_permalink().'”>’.get_the_title().'</a></div> <p>’.get_the_resume(60).'</p><!– THIS FUNCTION NEEDS TO BE CREATED –> </div> </div>’; Do not use ; trailers when using inline php, ex <a href=”‘.get_permalink().'”>. Use the appropriate return functions: get_the_post_thumbnail() get_permalink() get_the_title() Create a return version of the_resume() function Do use the … Read more
Try this one <?php $date_today = time(); $args = array( ‘post_type’ => ‘birthday’, ‘posts_per_page’ => 1, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘field_position’, ‘value’ => ‘Teacher’ ), array( ‘key’ => ‘field_dob’, ‘value’ => $date_today, ‘compare’ => ‘=’, ) ) ); $the_query = new WP_Query($args); if($the_query->have_posts()) : while($the_query->have_posts()): $the_query->the_post(); the_title(); endwhile; endif; ?>
You can set the posts_per_page with pre_get_posts action like this: add_action( ‘pre_get_posts’, ‘my_set_posts_per_page’ ); function my_set_posts_per_page( $query ){ if ( is_admin() ){ return; } //Check if this is a search if ( isset( $query->query[‘s’] ) ) { $query->set( ‘posts_per_page’, -1 ); } }
WordPress sets the php timezone to UTC for internal calculations. So at 4pm PST, date() will be producing a date that reads 10pm UTC. Hence the event is considered past. There are two ways to resolve this. (The preferred method) Store dates in the database in UTC. Handle all date calculations in UTC, and convert … Read more
Get posts with any value in attribute
Ok – it’s not the prettiest way to solve this, but this is what I came up with. Using a combination of session storage and a little javascript. First – I added session_start() to the beginning of my file. Then in query_posts_by_status I added $_SESSION[‘request_status’] = $request_status. This gave me access to the global $_SESSION … Read more