Using WP_Query To Get Posts Randomly From today

I don’t think there is a parameter value Today as you used in date_query. If you want to return today’s post then you should provide date value to date_query as you stored current date in $today array. So here is your query now. $today = getdate(); $args = array( ‘tag_slug__in’ => array( ‘destacado’), ‘posts_per_page’ => … Read more

ajax category filter

Not sure if you’ve solved this or not but I was looking for a way to embed this within a page and filter posts by category. I got this working so it displays all categories and the posts related. Put that in functions.php function ajax_filter_posts_scripts() { // Enqueue script wp_register_script(‘afp_script’, get_template_directory_uri() . ‘/js/ajax-filter-posts.js’, false, null, … Read more

Executing Queries in tag.php

That’s because the main query is being discarded and replaced with your custom query. You’ve not told your custom query to look for that tag, so why would it? You might also notice your pagination is broken for the same reason, you’ve not told the new query which page you’re on, so why would it … Read more

How to get random posts and order them by date

Unfortunately, that will never work. ‘rand’ is a random order, so you always end up with a randomized order, no matter what you put for the date. In order to do something like what you’re describing, you have to use ‘orderby’=>’rand’. Then you can sort the result by date. $query = new WP_Query( [ ‘post__in’ … Read more

Given a WP_Query, how can I get a list of tags?

I don’t think that is possible. The SQL query performed by WP_Query returns only the post objects (and perhaps some metadata), while the tags resides in a different table. When looping through the returned posts in templates you usually put the_tags(); or something similar in your templates, which in turns runs a new database query … Read more

replace the WP_Query class in the main query

Ok so it’s doable but could potentially mess up a few things down the line so it’s at your own risk, but then so is everything 🙂 I’ve been trying to do this in order to use a GeoQuery extension class to order events by distance from some location. The simplest way to do it … Read more

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