Best way to load page content in Fancybox popup?

I have found that the best way to include WordPress pages into a fancybox is to create a new template to use for those pages. For example I have some of my contact forms in a fancy box and the template I use is called custom-page-plain.php and doesn’t call header.php and contains a link to … Read more

WordPress Custom Query

<?php $querystr = ” SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = ‘date_field’ AND wpostmeta.meta_value=”03/11/2010″ AND wposts.post_status=”publish” AND wposts.post_type=”post” ORDER BY wposts.post_date DESC “; $pageposts = $wpdb->get_results($querystr, OBJECT); ?> Then you would access $pageposts as an object

How to hook get_terms() to only show count of posts that have custom meta

As far as I remember counts for terms are stored in database, so there is nothing to modify when you fetch them – you simply get ready-made numbers. So you will either need to implement and maintain your special logic for counts completely separately or try to recalculate and modify native counts, see wp_update_term_count_now().

Display Posts by modifying the where clause only for my query

If you’re going to add the filter on the where clause, then just make sure you remove it using remove_filter() and the exact same signature immediately after you create the query. In your example, you’re using query_posts(), so add the filter, run your query, and then remove your filter right afterward. add_filter( ‘posts_where’, ‘my_posts_where_filter’, 10, … Read more

Improve or optimize a very slow query

Persuming “article_datetime” to be a numeric value, I would suggest that instead of using ‘orderby’ => ‘meta_value’ use ‘orderby’ => ‘meta_value_num’ If still query is slow, than remove: ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘article_datetime’, ‘order’ => ‘DESC’ and instead sort the result in php.

Why is it necessary to call rewind_posts() when using the loop more than once? [duplicate]

Global rewind_posts File: wp-includes/query.php 784: /** 785: * Rewind the loop posts. 786: * 787: * @since 1.5.0 788: * 789: * @global WP_Query $wp_query Global WP_Query instance. 790: */ 791: function rewind_posts() { 792: global $wp_query; 793: $wp_query->rewind_posts(); 794: } and rewind_posts from WP_Query class. File: wp-includes/class-wp-query.php 3144: * Rewind the posts and reset … Read more

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