Unique Problem with the php date and get_posts

date returns a string but you are using integers in the switch statement. Use: case ’01’: $dateY = date(‘Y’)+1; break; etc. However, the switch code can be much simpler, and there is no need to call the date function again since dateY has already been initialised in advance: switch($dateM) { case ’01’: case ’02’: case … Read more

Query post with meta value in set of values

Check This Will Work for you. $args = array( ‘post_status’ => ‘any’, ‘post_type’ => ‘any’, ‘numberposts’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘Asin_unique’, ‘value’ => array(‘B006MWDNVI’,’B00BCMCIS2′,’B01ARRJFGA’), ‘compare’ => ‘IN’, ) ) ); $posts = get_posts( $args ); Help Link: https://rudrastyh.com/wordpress/meta_query.html

Get all posts which was posted on X Days WordPress

You can try following code $y = date(‘Y’); $m = date(‘m’); $d = date(‘d’,strtotime(“-7 days”)); //Date you want $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ‘date_query’ => array( array( ‘year’ => $y, ‘month’ => $m, ‘day’ => $d, ), ), ); $posts= new WP_Query( $args ); //you will get posts which are posted … Read more

Best choice for multiple loop in page?

get_posts() is just a wrapper for WP_Query, however it does have two main differences: get_posts() just returns an array of posts, so doesn’t provide methods for a Loop. get_posts() sets the ignore_sticky_posts and no_found_rows arguments to true. no_found_rows is required for pagination, and disabling it improves performance. #1 means means that you need to use … Read more

Inserting post content into pages when using custom taxonomies

That code never outputs anything to the page: <?php if(has_term(‘ART’, ‘product_relevance’)): $my_post = get_post(927); if(isset($my_post->post_content)): ?> <div class=”row”> <div class=”notification col-lg-9 order-1″> <?php echo $my_post->post_content; ?> </div> </div> <?php endif; ?> <?php endif; ?> Untested, but in essence you need to do something with the post content.

Recoverable Fatal Error – Object of class WP_Post could not be converted to string

the_title doesn’t work that way: the_title( $before, $after, $echo ); $before is the text that comes before the title, but you didn’t give it a string/text, you gave it a post object. Post objects aren’t strings, PHP doesn’t know what to do so it stops and prints an error instead. For the_title to work, you … Read more

Iterate over get_post_meta() result

You’re clobbering the value in the $users array with every iteration of the foreach loop. To add a new item to an array, you should use $users[] = {…}, not $users = {…}. function get_preselect_values() { $volunteers = get_post_meta($_POST[‘element_id’], “volunteers”, false); $users = array(); foreach ($volunteers as $volunteer) { foreach ($volunteer as $volun) { $users[] … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)