date_query not returning some posts in date range

Your syntax is incorrect for your date_query. It should be an array of an array, not just an array. I also suspect that your problem might be related to PHP and not WordPress. Your before date is invalid. PHP only supports dates between 13 December 1901 and 19 January 2038, so your dates need to … Read more

get posts based on meta value of the author

Get for all users / authors with user meta field. meta1 = true $args = array( ‘meta_key’ => ‘meta1’, ‘meta_value’ => ‘true’, ‘meta_compare’ => ‘=’, ‘fields’ => ‘all’, ); $users = get_users( $args ); Store user id and login into an array authors $authors = array(); foreach ( (array) $users as $user ) { authors[ … Read more

How to restore deleted pages/posts?

Then you should see a link “Trash” on the top of pages/posts listing section. Click on that link which will take you the section where all the trashed pages/posts are listed. Select the pages/posts using the checkboxes against them. Select Restore from Bulk Actions dropdown, then hit the Apply button. Now go to pages/posts listing … Read more

get_posts with meta_compare=’LIKE’ not working

meta_compare Possible values are ‘!=’, ‘>’, ‘>=’, ‘<‘, or ‘<=’. Default value is ‘=’ if you want to use LIKE you need to create a meta_query eg: $tolettpe = “Sale”;//default if($_REQUEST[‘tolettype’]) $tolettpe = $_REQUEST[‘tolettype’]; else if($_REQUEST[‘srch_type’]) $tolettpe = $_REQUEST[‘srch_type’]; $args = array( ‘numberposts’ => $latestcount, ‘category’ => $catidstr, ‘meta_query’ => array( array( ‘key’ => ‘property_type’, … Read more

How to get current post ID in quick edit callback

You can get the ID per JavaScript from the quick edit screen’s parent tr: that has an attribute id=”edit-418″, where 418 is the post ID. So extract this number, get the post data per AJAX, and insert the values you need. Not elegant. Read wp-admin/js/inline-edit-post.js to see how the core does it.

get_post random and order by not working

Yes, this is the correct syntax: $args = array( ‘orderby’ => ‘rand’, ‘order’ => ‘ASC’ ); query_posts( $args ); However plugins can keep this from working properly. Try disabling ALL plugins and see if that helps. Two known plugins which keep orderby=rand from working are Post Type Order and WP_Sticky Also, if you have Post … Read more

WordPress get_posts by category

In all probability you are using a custom taxonomy, and not the build-in category taxonomy. If this is the case, then the category parameters won’t work. You will need a tax_query to query posts from a specific term. (Remember, get_posts uses WP_Query, so you can pass any parameter from WP_Query to get_posts) $args = [ … Read more

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