WP_Query on meta returns featured posts (mismatch meta query)

When migrating a site to WordPress, old URLs should be redirected

So I've created a function that intercepts 404 and looks for a meta value that matches the number in the URL that should be redirected.

It worked like a charm until a user posted a new article and made it sticky. This query returned the sticky post and ignored the meta query

I have tried many things to correct that which did not work that way 'suppress_filters' => true

in case of emergancy 'post__not_in' => get_option( 'sticky_posts' ) did the trick, but that's not the way. (If this post I wanted was sticky, he would not find it!)

How can I then create a WP_Query that receives a post via meta-query and does not insert sticky posts?

add_action( 'template_redirect', 'wpd_do_stuff_on_404' );
function wpd_do_stuff_on_404(){
    if( is_404() ){

        $url = $_SERVER('REQUEST_URI');

        if (preg_match('//(d+)-(^/)*$/', $url, $matches) ) {
            // looks like a dc post, lets try to find a post using dc_post_id
            $dc_post_id = intval($matches(1));
            $args = array(
               'meta_query' => array(
                       'key' => 'dc_post_id',
                       'value' => '' . $dc_post_id,
                       'compare' => '=',
               'suppress_filters' => true,
               'posts_per_page' => 1,

            $q = new WP_Query($args);

            if ( $q->post_count == 1 && $q->max_num_pages == 1 ) {
                wp_redirect( get_permalink( $q->posts('0')->ID ), 301 );

Postgresql – Postgres – Why is the scheduling time for a query longer than the execution time?

I work with a customer who has migrated from Oracle to Postgres and has slow query performance. During query performance troubleshooting, EXPLAIN ANALYZE returned:

Planning time: 8143858.55 ms
Execution time: 20.1 ms

Why is the planning time ~ 2.2 hours compared to the execution time of 20 hours? After the migration, all tables were manually parsed to keep statistics up-to-date. It looks weird to me. I'm looking for guidance on some of the other things I may need to check for further troubleshooting.


Database – 8 – To create a query node that queries content with more than one comment

Consider this example:

  $query = Drupal::entityTypeManager()->getStorage('node')->getQuery();
  $nids = $query->condition('type', 'question')
    ->condition('status', 1)
    ->condition('field_category', $tid)
    ->sort('created', 'DESC')
  $questions = Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);

I just want to query the questions with answers. (these are comments)
I was hoping to add ->condition('comment_node_question.0.comment_count', '0', '>') would work, but no luck.

Database – How do I query something if I do not know how it is structured?

I would have to know the situation where you had to do that better, otherwise my answer might not be what you are looking for.

In general you know the structure; Either you have created the application and thus the tables, and of course you know its structure, or the person who created it, has documented it for you, or you have provided a script to create the tables that you can read ,

If you fell from the sky and none of these conditions apply, you need to know at least which database you are connecting to and have a command-line client. Then review the documentation for that particular database to find out how to check user-created tables. For example, MySQL / MariaDB lists the existing tables:

show tables;

And this returns the statement that created a specific table:

show create table ;

How do I combine the same value for the Google Sheet query?

I'm trying to create a separate tab in my Google Sheet where I can filter the trainer to see which days he's doing Day 1 and Day 2 training.

Day 1 Training:

= iferror (Query (& # 39; Hiring Tracker & # 39;! N: Q, & quot; Select N Where O = & # 39; & A2 & quot ;, and N> = Date & # 39; & gt; & GG; & gt; & "# By N asc", 0))

Day 2 Training:

= iferror (Query (& # 39; Hiring Tracker & # 39;! N: Q, & quot; Select P Where Q = & # 39; & A2; & # 39; and P> = Date & # 39; & GG; & gt; & "# Order by P asc", 0))

Instead of displaying several identical dates, I can also combine the same values ​​to indicate which days the coach is training. The graphic on the right is what I want, and the graphic on the left is what I have right now.

Enter image description here

Training Doc

Page Query List with orderByChild (Firebase-PHP)

I consult a list that is sorted by attr (numerical) and I try to paginate it again startAt and limitToFirst, The problem is that the query always triggers the same thing n records

This is the code segment:

$lastId = $_POST('id') ? $_POST('id') : '';

$result= $db->getReference('books')->orderByChild('year')->startAt($lastId )->limitToFirst(10);

Could you help me, what am I doing wrong?

SEO – Using prerender.io to cache article pages with query strings

My website is running on SPA Angular 7. Currently I use prerender.io to cache the home page (/ # / home) without any problem.

My question is, I want prerender.io to cache my article page, which displays dynamic article content based on the article ID specified under the URL query string. e.g. www.example.com/#/article?id=5

How do I make sure that all article content / pages are cached? Do I need to add any URL with a different query string ID (? Id = 1,? Id = 2, and so on) in prerender.io Dashboard?

wp query – A WP_Query with multiple loops with different parameters

I create a page where 8 random posts must first be displayed. Then display all the posts with the A-Z title order on the second page, and so on with the previous / next pager.

does rewind_posts() allow to use different parameters with the same query? Is there another way, if not?

$q = new WP_Query((
    'post_type' => 'staff',
    'posts_per_page' => 8,
    'orderby' => 'rand',
    'order' => 'ASC',
if ($q->have_posts()) :
    while ($q->have_posts()) : $q->the_post();

Parameters for the second loop.

'orderby' => 'title',
'order' => 'ASC',
'paged' => $paged,

t sql – mysql query to find the last entry for each of the last 7 days

I have a table that contains a timestamp and a number for each line. These data are recorded every 15 minutes in the quarter hour, 24 hours a day, but are sometimes overlooked or delayed. I want to be able to extract the data for the end of the last 7 days, including the most recent one from today. I have two different questions that almost reach this, but not quite:

FROM WaterDepth 
WHERE (date >= DATE(NOW()) - INTERVAL 7 DAY) AND (HOUR(date)+MINUTE(date) = 68) 

This captures the last 7 days at 11:45 pm, but skips any days when there is no entry at 11:45 pm and omits today's days.

SELECT a1.* 
FROM WaterDepth a1 
INNER JOIN (SELECT max(date) as max 
            FROM WaterDepth 
            GROUP BY date(date)) a2 ON a1.date = a2.max

It captures the last entry for each day, regardless of the current time, but I'm not sure how to limit it to the last seven days. I guess I look like a mixture of both.

thank you in advance