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.

Delete all posts from WordPress except latest X posts

The offset parameter is ignored with posts_per_page set to -1 in WP_Query. If you look at the source code in the WP_Query class, posts_per_page=-1 sets nopaging to true. if ( !isset($q[‘nopaging’]) ) { if ( $q[‘posts_per_page’] == -1 ) { $q[‘nopaging’] = true; } else { $q[‘nopaging’] = false; } } This in turn will … Read more

Getting the Intersection of Two Custom Taxonomy Terms for a Custom Post Type?

As of v1.3, the Query Multiple Taxonomies plugin works great with WP_Query. Your original args work as is. $args = array( ‘post_type’ => ‘portfolio’, ‘numberposts’ => -1, ‘project_type’ => ‘A’, ‘package’ => ‘A’ ); Then make a new query and check it: $foo = new WP_Query($args); var_dump($foo->posts); I tested this on my own custom taxonomy … Read more

Using get_posts vs. WP_Query

This is directly related to, and a consequence of WordPress.com VIP At VIP, we deal with sites that range in the hundreds of millions of page views per week. As a result, situations that can slow down your site are much more noticeable at that scale than on a small shared host, but this still … Read more

How to order by post_status?

You can use ‘posts_orderby’ filter to change the SQL performed. Note that: using get_posts() you need to set ‘suppress_filters’ argument of false for the filter to be performed if you don’t explicitly set ‘post_status’ you’ll get only published posts (so no much to order) Code sample: $filter = function() { return ‘post_status ASC’; }; add_filter(‘posts_orderby’, … Read more

exclude category from get_posts?

as ‘get_posts()’ uses the ‘WP_Query()’ parameters, i would assume that this should work: $laargsM = array( ‘cat’ => 7, ‘posts_per_page’ => 300, ‘orderby’ => ‘title’, ‘order’ => ‘asc’, ‘category__not_in’ => array(10) );

get all posts ID from a category

The thing to remember about get_posts is that is uses a WP_Query object internally. get_posts source: <?php /** * Retrieve list of latest posts or posts matching criteria. * * The defaults are as follows: * ‘numberposts’ – Default is 5. Total number of posts to retrieve. * ‘offset’ – Default is 0. See {@link … Read more

How to get all posts related to particular category name?

Just use WP_Query() to generate your custom query, using the category parameters. Assuming you know (or know how to get) the ID of the specific category, as $catid: <?php $category_query_args = array( ‘cat’ => $catid ); $category_query = new WP_Query( $category_query_args ); ?> Note: you could also pass the category slug to the query, via … Read more

get_children() Not Working with orderby Parameter

Are you sure you need this specific function? Documentation (both Codex and inline) is verrry confusing. And it supposedly fetches things like attachments, which probably aren’t relevant for navigation… Try this: get_posts( array( ‘post_type’ => ‘page’, ‘post_parent’ => $parent->ID, ‘orderby’ => ‘menu_order’ ) );

Get posts from Network (Multisite)

I created a plugin which does something similar (called Multisite Post Display https://wordpress.org/plugins/multisite-post-reader/ ) . It displays posts from all multisite sub-sites. The code in there might be helpful for what you are doing. You are welcome to dig into it and use the code to help with your project. (After all, I used other … Read more

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