Get number of comments after modifying comment query

Refrain from editing core files WordPress was developed with extensibility in mind, and provides many ways to change the appearance and functionality of an installation without altering the WordPress software itself (mostly using Hooks in conjunction with Plugins and Themes). The software is comprised of it’s “core files”, which are generally everything outside of the … Read more

Using next/previous_posts_link with customised search

You don’t need the type variable and other bits of custom search query code, or custom functions like the other answers. In your searchbox, instead of submitting the form to / submit it to /my_post_type/ instead! WordPress will handle all the rest for you automagically, with no effort involved. What’s more this means all the … Read more

Trying to list out child pages with WP_Query

I tested the query and it does work so the only thing I can spot that is misleading but not right is directly after you while() statement you have the_post(). This doesn’t work in secondary queries, it should look like: <?php if( $subpages->have_posts() ) : ?> <?php while( $subpages->have_posts() ) : $subpages->the_post(); ?> … <?php … Read more

How to order posts by custom WP role?

you can add a custom field to each listing post with the user’s role and then in your query you can order by that field, for example say you have a custom field named `u_role’ then your query should look like this: $custom_role_query = new WP_Query( array( ‘author’ => implode( ‘,’, $custom_ids ), ‘post_type’ => … Read more

Looping through tabular data

The biggest problem here is syncing between two dissimilar sets of data. This looks like a good use-case for @scribu ‘s Posts2Posts plugin. Once you’ve installed that, you can create a direct correlation between the different post-types and query that connection.

How to user WP_Query to lower the number of queries

The big issue you have here is calling your post thumbnails. That adds about two queries per post, which is quite heavy. When we look at the source code of get_the_post_thumbnail(), we will see that the thumbnails is only cached on the main query, and not custom queries. So we would need to do that … Read more

WP_Query meta_query by array key

You can’t do that. When you save postmeta (or any other meta, for that matter), WordPress runs it through maybe_serialize which turns objects and arrays into serialized data. When it gets pulled back out, it is run through maybe_unserialize. Serialized data looks something like this: a:1:{s:3:”one”;s:3:”two”;} In other words, what get’s stored cannot be queried … Read more

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