WP Query outputs three items within a div

You can use the variable $current_post, something like this. <?php $query = new WP_Query(array( ‘post_type’ => ‘custom_job’, ‘showposts’ => 12 ) ); ?> <?php while ($query->have_posts()) : $query->the_post(); ?> <?php if ($query->current_post % 3 === 0) :?> <?php $numbers = array(‘One’, ‘Two’); //add the rest ?> <div class=”jobs<?php echo $numbers[floor($query->current_post / 3)];?>”> <?php endif;?> <div … Read more

3 queries to update WordPress

Sounds like you’re trying to do it the old and hard way. When you add a fresh install of WordPress, it will ask you for the database information. You would need to create a mySQL database, set a user for that database, and then import the contents from the old database to the new one … Read more

WooCommerce Total # orders [closed]

You can use this following query to get the total number of orders. $order_totals = apply_filters( ‘woocommerce_reports_sales_overview_order_totals’, $wpdb->get_row( ” SELECT COUNT(posts.ID) AS total_orders FROM {$wpdb->posts} AS posts LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) LEFT JOIN {$wpdb->terms} AS … Read more

Query parsing only author ids

Assuming that you have an array of post objects in $my_posts… $authids = array_unique(wp_list_pluck($my_posts,’post_author’)); What you will get are the post authors for the current page of posts, not the post authors for all of the posts. If you want the authors for all of the posts you will have run another query. To run … Read more

Custom Query for wp_posts using wp_postmeta

While you might not want / be able to use native query, it is still the easiest and most reliable way to generate SQL like that. $wpdb->last_query will remember last query performed and defining SAVEQUERIES constants will make $wpdb->queries contain all of the queries performed in current load (not advisable in production for performance). So … Read more

query posts only works on the first page

As @Pieter Goosen said, you shouldn’t be using query_posts, nor running your own query. Instead, override the main query that already runs: function wpse_144974_pre_get_posts( $wp_query ) { if ( ! is_admin() && $wp_query->is_main_query() && is_home() ) $wp_query->set( ‘cat’, 1 ); } add_action( ‘pre_get_posts’, ‘wpse_144974_pre_get_posts’ );

List of buyers for each product

Goto your wordpress phpmyadmin open database 1.All Woocommerce orders save in table-prefix_posts table 2.and Woocommerce order’s meta info like :billing-addres,customer-name store in table-prefix_postmeta table run SQL command in phpmyadmin SELECT * FROM `table-prefix_postmeta` WHERE `post_id` = any order-id LIMIT 0 , 30 you get list of product meta info. _order_items this meta-key store all product … Read more

Delete query won’t run

I see no reason why $_POST[‘delete’] should not be set assuming there are no page redirects involved. I can’t tell from your code if that is the case, but it superficially appears not to be. I do see other potential problems. You are setting your form action to an empty string. While that does sometimes … Read more

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