List all posts from past week grouped by sub-category

I would recommend that you use WP_Query for this one: $categories = get_categories( ‘child_of=83’ ); foreach ( $categories as $category ) { echo ‘<h3>’ . $category -> name . ‘</h3>’; echo ‘<ul>’; // create a WP_Query that retreives all posts from the specified // category which is older then 1 week $args = array( ‘cat’ … Read more

Alter a specific query on WordPress

You might be able to use the query filter hook See this WPSE answer Basically, you can do something like: add_filter( ‘query’, ‘your_filter_function’ ); function your_filter_function($query_sql) { // do something to $query_sql return $query_sql; } This will get called for every query, so you’ll need to test $query_sql to make sure it’s the query you … Read more

Temporarily storing main search result

The way I see it, you have three options: Store the global search data in $_SESSION Store the global data in a transient Run the query twice, with & without the post type filter I tried storing the array in a global variable and as soon as the page refreshes with the refined search results, … Read more

Style Post Differently In Query

You can set an array for the class of the div, and then inser the value of that variable as a class in the div. And create those classes in your stylesheet. In your code, the_thumbnail is inside the if($i==0), so it only prints when $i==0. Then the what’s outside the if prints just titles, … Read more

Query Strings and Woocommerce

I think that I figured this out. In my functions.php file I had the below function to redirect to the checkout page when a product is added to the cart. So I captured the username variable there and then added it to the redirected URL: add_filter (‘add_to_cart_redirect’, ‘redirect_to_checkout’); function redirect_to_checkout() { global $woocommerce; $checkout_url = … Read more

Search query -> Show all pages except certain template

REWORKED ANSWER TO ANSWER THE QUESTION In order to exclude all pages with a certain template, all you need to do is to run a meta_query to exclude all pages with the custom field _wp_page_template set to bedankt. Remember, WordPress saves the template assigned to a page as a hidden custom field called _wp_page_template With … Read more

Getting post data from private page

setup_postdata takes a post object of type \WP_Post, but you’re passing it a WP_Query instead e.g. global $post; setup_postdata( $post ); Thankfully the solution is trivial, when you call the_post, it sets up the current post data for you, so removing that line is all you need to do. The second issue is that WP_Query … Read more

Get post according to current taxonomy

Try this for WP_Query $args = array( ‘post_type’ => ‘example’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘identite’, ‘field’ => ‘ID’, ‘terms’ => $term->term_id ) ), );// end args OR $args = array( ‘post_type’ => ‘example’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘identite’, ‘field’ => ‘ID’, ‘terms’ => array($term->term_id) ) … Read more

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