why does wordpress ignore the post args?

There is no category argument: cat (int) – use category id. category_name (string) – use category slug (NOT name). category__and (array) – use category id. category__in (array) – use category id. category__not_in (array) – use category id. You want to be using the category_name argument– note that it takes the slug not the name–, though … Read more

Bulk delete WordPress posts with phpMyAdmin

The join isn’t that complex, but I wouldn’t bother with it. Since you have a lot to remove a direct SQL query will run a LOT faster than WP. However, we do need to keep track of the post ID numbers and remove the descendants and metadata. Not tested / Make a backup / your … Read more

Get Value of Post before

<?php $previous_post=null; if ( have_posts() ) { while ( have_posts() ) { the_post(); global $post; if($previous_post!=null) { /// Do what ever you want to do with previous post $previous_post. } $description = get_post_meta( get_the_ID( ), ‘metabox_description’, true ); echo $description; // Add: echo $description_from_post_before; $previous_post = $post; } // end while } // end if … Read more

Nested WP_Query breaking loop

This can be done in a single query: $parent_only = new WP_Query( array( ‘post_parent’ => 0, ) ); If you want to have all children of a specific page (for e.g.) in the loop (or on a request that returns TRUE for is_singular()), use get_the_ID() as argument for post_parent. Edit (after seeing the full loop … Read more

WordPress does not output “post” class when calling post_class() function

get_post_class() generates and returns the list of classes echoed by post_class(). The only reason for the function itself not producing the result you want can be found in the source post-template.php: if ( ! is_admin() ) $classes[] = $post->post_type; Which means that the class post actually only gets generated if is_admin() doesn’t apply. Another possibility … Read more

What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?

You can also do it this way – plugin free. Open phpmyadmin, browse over to your wp_posts table and: SELECT * FROM `wp_posts` WHERE post_type=”revision”; to see all the posts, their types and revisions and delete from `wp_posts` WHERE post_type=”revision” Though afraid at first…I did it. And it worked without any impact to the site.