the loop – how to control whether wp or plug-in runs it

The problem was in my the loop.php file, i was executing a new loop using the wordpress parameters for the main loop, which caused a duplication with the plugin being used (thecartpress) which executes its own loop. I was using: global $post, $query_string, $discTheme; query_posts($query_string); in a sense, with thecartpresses own loop, I was duplicating … Read more

$query conflicting with other queries in the same page

function pre_get_posts( $query ){ if(isset($query->getpostlist) && $query->getpostlist) { add_filter( ‘posts_fields’, ‘postsetupFields’, 20); } else { remove_filter( ‘posts_fields’, ‘postsetupFields’, 20); } return $query; } function postsetupFields( $fields ){ global $wpdb; $fields = “{$wpdb->posts}.ID”; return $fields; } add_action( ‘pre_get_posts’, ‘postsetupFields’);

Display posts where date field matches current month?

You can use the meta_query parameter to display all events for the current month like this: $start_date = date( ‘ym01’ ); $end_date = date( ‘ymt’ ); $meta_query = array( ‘key’ => ‘event_date’, ‘value’ => array( $start_date, $end_date ), ‘compare’ => ‘BETWEEN’, ‘type’ => ‘NUMERIC’ ); $args = array( ‘post_type’ => ‘hh_event’, ‘posts_per_page’ => -1, ‘orderby’ … Read more

Multiple loop for “featured” items returns wrong posts

Your second loop is fine because it works – although it is probably more efficient to do it this way: $args = array( ‘post_type’ => ‘onourradar’, ‘posts_per_page’ => -1, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘offset’ => ‘2’); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); The difference is that a do_not_duplicate query is just … Read more

loop through custom post-type with two meta_keys

You’ll need to use meta_query along with meta_(key|value|compare) to interact with two different keys and get the order you want. <?php $q = new WP_Query(array( ‘post_type’ => ‘my_project’, ‘nopaging’ => true, // same as posts_per_page => 1, ‘order’ => $order, ‘orderby’ => ‘is_featured_position’, // your position key here ‘meta_key’ => ‘is_featured_position’, // also here, see … Read more

get all page templates

Only the page post type can have a template assigned (of the default post types), it’s the custom template you set in the Page Attributes meta box. If you have a page.php template file, your index.php will only be used to display post post types, so those posts will never have a _wp_page_template meta key. … Read more

Using Query In Post Type Archives

Change it from: ‘category_name’ => celebrity, ‘orderby’ => 1, into ‘category_name’ => ‘celebrity’, ‘orderby’ => ‘date’, // or something else Otherwise celebrity will be treated as a constant name, not a string. Also, you can’t order by 1, you have to use one of the ordering parameters.

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