Get ONLY the number of results in a query

There are three sides for the “efficiency” issue. From the DB side, most of the time is spent in traversing the DB tables. If you need all the rows, you need the DB to traverse all of them no matter what information will be returned. There is probably a cost associated with holding data in … Read more

WooCommerce shop page orderby [closed]

WooCommerce have moved this setting to the WordPress Customizer. From your WordPress admin area, browse to: Appearance -> Customise Then, from within the customiser, you can find the setting here: WooCommerce -> Product Catalogue and simply change the order under the option ‘Default Product Sorting’

WC displaying products from category

For custom taxonomies, including Product Categories, you should use the tax_query argument: $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 12, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘terms’ => 40, ), ), );

Remove a specific category ID from related post

from looking at https://developer.wordpress.org/reference/functions/wp_get_post_terms/ and https://developer.wordpress.org/reference/classes/wp_term_query/__construct/ for corresponding parameters, i.e. the ‘exclude’ parameter and https://developer.wordpress.org/reference/functions/get_category_by_slug/ to get the category ids from their slugs. it might work when you replace this line in your code: // Get the taxonomy terms of the current page for the specified taxonomy. $terms = wp_get_post_terms( get_the_ID(), ‘category’, array( ‘fields’ => … Read more

Check on which page specific result exist

You can select this term_id from the DB and add row number column in SQL Query and then you can calculate in which page it should be. For example: global $wpdb; $wanted_term = $wpdb->get_row(“SELECT terms.* FROM ( SELECT @rownum := @rownum + 1 AS rownum, t.*, tt.taxonomy FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS … Read more

How to create a WordPress Post Filter that users can use to filter posts by year?

I’m pretty sure you haven’t even try to search for solution… If you did, then I’m pretty sure you would came to this Codex page, where you can find this code: <select name=”archive-dropdown” onchange=”document.location.href=this.options[this.selectedIndex].value;”> <option value=””><?php echo esc_attr( __( ‘Select Month’ ) ); ?></option> <?php wp_get_archives( array( ‘type’ => ‘monthly’, ‘format’ => ‘option’, ‘show_post_count’ => … Read more