Problem when try to add ++1 for user meta

The problem here is twofold: the ++ operator is applied on an array. the user id and the meta key need to be swapped in get_user_meta() So use get_user_meta( $user_id, “_user_count”, true ); to get user meta. Note that the third input parameter is false by default and an array is returned. Setting it to … Read more

Query returning same results even though the ID changes

You can pass your meta query into query_posts or (the preferable) WP_Query in 2 ways: An array using the array keys meta_key, meta_value, meta_type and meta_compare An array of arrays using the array keys key, value, type and compare In your question, you were trying to use a mix of the two, and that’s why … Read more

How to change the amount of posts previewed on a page?

You’re missing an s. $query->set(‘posts_per_page’, ‘1’); However – you probably don’t want to do this for every query, since that affects everything – widgets, back end, everything. You should make it conditional. For example: <?php function university_adjust_queries($query) { // If this is the main query, not in wp-admin, and this is the homepage if($query->is_main_query() && … Read more

Multiple Category Query

Yes, it is. You’ll need a template page for the category (for example, category-30.php, where 30 is the id of the category you want to show with multiple subcategories). In the template, run through the standard loop for post from the original category if you want to, if not, the magic function will be wp_reset_query … Read more

Get Posts from Last 24 hours and Sort them via GD Star Rating

The posts_where filters the ‘WHERE’ part of the SQL statement, and not the query string. So $where .= “&post_date > ‘”.date(‘Y-m-d H:i:s’, strtotime(‘-24 hours’)).”‘”; should be $where .= ” AND post_date > ‘”.date(‘Y-m-d H:i:s’, strtotime(‘-24 hours’)).”‘”; Also as this hook is fired for every query (admin and public side), you should use some logic to … Read more

All in One Calendar Plugin Custom Post Type Query [closed]

Ok so hope this helps someone. Unless you want to query the database directly, the trick is to include the following: $event = Ai1ec_Events_Helper::get_event($post->ID); thereafter you can retrieve the variables, for example: <?php query_posts(‘post_type=ai1ec_event’);?> <?php while ( have_posts() ) : the_post(); ?> <?php $event = Ai1ec_Events_Helper::get_event($post->ID); ?> <?php echo ‘<h5><a href=”‘.get_permalink().'”>’.get_the_title().'</a></h5>’; ?> <?php if( $event->multiday … Read more

Exclude all sticky posts front page twenty twelve

Don’t use query_posts. Use a filter on pre_get_posts. function no_front_sticky_wpse_98680($qry) { if (is_front_page()) { $qry->set(‘post__not_in’,get_option( ‘sticky_posts’ )); } } add_action(‘pre_get_posts’,’no_front_sticky_wpse_98680′); By running query_posts you clobber the main query, over-writing it with another query. That is why you break pagination. The new query gets out of sync with what should be the main query.

I can’t figure out what’s wrong with this statement. $wpdb->query update

Without an error message, it is difficult to tell the exact problem. It is important to debug within WordPress and check your webserver error logs. One problem is your call of prepare(). The method takes 2 or more arguments, you only passed 1. Instead try the following $update_status = $wpdb->query($wpdb->prepare( “UPDATE {$wpdb->prefix}wcpv_commissions SET commission_status = … Read more

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