Tag Info

Hot answers tagged

7

First of all you really shouldn't be using query_posts(). Read this excellent explanation why. Then this is a perfect use case for transients. You just get the post once and then cache it for 24 hours using the Transients API. if ( false === ( $quotes = get_transient( 'random_quote' ) ) ) { // It wasn't there, so regenerate the data and save the ...


3

The alternative way to handle this problem is to use paginate_links() with get_comments() (or any similar query). Specifically to get the equivalent of max_num_pages, you can use the built-in function wp_count_comments(). So, to get your maximum number of pages, you'd first produce a count of all the comments you want. Presuming you don't want unapproved ...


2

An easy query like the following should work for you: <?php $_query = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => -1, 'post_status' => 'publish', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'key1' ...


1

$count is just an arbitrary variable name. If you're using a separate loop to get tags and stop after a certain number (as shown on https://codex.wordpress.org/Function_Reference/get_the_tags), replace the $count variable in that example code with something like $tag_count or $counting or $treebark, and it won't mess up your use of $count in the posts Loop ...


1

You need to pass author__in as an array but that isn't what you doing with this: ( array( 'author__in' => array( $followed ) ) ). You are creating an odd set of nested arrays. WP_Query isn't going to know what to do with it. A much simplified version should work: $followed = $wpdb->get_col(" SELECT user_id1 FROM wp_um_followers WHERE user_id2 ...


1

First of all you are trying to combine both of the tables by post_parent. $wpdb->posts.post_parent = $wpdb->ftcalendar_events.post_parent I guess data in the ftcalendar_events has children of posts table, try $wpdb->posts.ID = $wpdb->ftcalendar_events.post_parent Also you can try joining tables: SELECT * FROM $wpdb->posts JOIN ...


1

Strictly regarding your question: get_object_taxonomies( 'user' ); since user is the $object_type that it is used when the author registers the taxonomy.


1

I wouldn't say it's not "normal", but it's above typical. The common minimum of queries would go like: main query (set of posts) functionality (menus, widgets, etc) data (terms and such) On a WP test data that would make something under 50 queries on home page. With object cache it will fall under 10 on repeat visits. Without knowing your set up — yes, ...



Only top voted, non community-wiki answers of a minimum length are eligible