Wednesday, February 1, 2023
HomeWordPress Developmentphp - Three totally different queries on identical web page

php – Three totally different queries on identical web page


I am attempting to show three totally different queries with identical put up sort, taxonomy, post__in argument and totally different taxonomy time period for every of them. Factor is, that first question return posts and not using a drawback, however different two under no circumstances.

That is the primary time i’ve encountered one thing like that and i am utterly at loss right here.

The thought is:
To filter every question by particular phrases from customized taxonomy and by listing of specified ID’s from array.

Issues i’ve tried:

  • switching to meta_query as an alternative of “post__in” argument,
  • giving slugs to tax_query subject as an alternative of ID’s

Extra infos:

  • The $tm_specs returns serialized array, so it is the right supply
  • If i simply take away first question in any respect, then the opposite two nonetheless not renders.

The bizarre factor is that if i take away both tax_query or post__in from the second or third question then it renders correctly.

I might actually admire any assist in that matter.

The code:

$ts_args = array(
    'post_type' => 'specjalizacja',
    'posts_per_page' => -1,
    'post__in' => $tm_specs,
    'tax_query' => array(
        array(
            'taxonomy' => 'kategoria',
            'subject' => 'ID',
            'phrases' =>  2,
        ),
    ),
);
$ts_loop = new WP_Query($ts_args);

$fy_args = array(
    'post_type' => 'specjalizacja',
    'posts_per_page' => -1,
    'post__in' => $tm_specs,
    'tax_query' => array(
        array(
            'taxonomy' => 'kategoria',
            'subject' => 'ID',
            'phrases' =>  3,
        ),
    ),
);
$fy_loop = new WP_Query($fy_args);

$dtb_args = array(
    'post_type' => 'specjalizacja',
    'posts_per_page' => -1,
    'post__in' => $tm_specs,
    'tax_query' => array(
        array(
            'taxonomy' => 'kategoria',
            'subject' => 'ID',
            'phrases' =>  4,
        ),
    ),
);
$dtb_loop = new WP_Query($dtb_args);

<?php whereas ( $ts_loop->have_posts() ) {
    $ts_loop->the_post();
        echo '<a href="'.get_the_permalink().'" class="bordered-btn-big"><span>'.get_the_title().'</span></a>';
} wp_reset_postdata(); ?>

<?php whereas ( $fy_loop->have_posts() ) {
    $fy_loop->the_post();
        echo '<li class="bordered-btn"><a href="'.get_the_permalink().'"><span>'.get_the_title().'</span></a></li>';
} wp_reset_postdata(); ?>

<?php whereas ( $dtb_loop->have_posts() ) {
    $dtb_loop->the_post();
            echo '<li class="bordered-btn"><a href="'.get_the_permalink().'"><span>'.get_the_title().'</span></a></li>';
} wp_reset_postdata(); ?>

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments