Infinite loop ignores taxonomy and category settings…

Posted in: Newspaper
Post count: 101

For our site we have created an abc index for our posts.
We have a taxonomy built called “alphabetical_letter” which houses all the articles, which are on their own again divided into live-review, album-review and so forth.

We are now in the process of making seperate loop files/taxonomy files.
In our example we did this for the letter N for muziekrecensies category, so that this will display only all articles marked with the category muziek-recensies and the taxonomy alphabetical letter N, using the code further below.

The loop has been set for the first 30 posts, only strange thing is that after this the load more function from the theme kicks in, and displays all articles, not just the ones with the keyword N in the alphabetical letter taxonomy, but all the other ones from the category muziekrecensies.

Is there a way to solve this please ?
the page where this is happening can be seen here (posts currently set to -1 for reviewing reasons):

for the loop-albumrecensies.php
<?php
/**
* If you are looking for the loop that's handling the single post page (single.php), check out loop-single.php
**/

// $global_flag_to_hide_no_post_to_display - comes from page-category-big-grid.php and is a flag to hide the 'No posts to display' message if on category page there are between 1 and 5 posts
global $loop_module_id, $loop_sidebar_position, $global_flag_to_hide_no_post_to_display;

///if we are in wordpress loop; used by quotes in blocks to check if the blocks are displayed in blocks or in loop
td_global::$is_wordpress_loop = true;

$td_template_layout = new td_template_layout($loop_sidebar_position);

if (empty($loop_module_id)) { //not sure if we need a default here
$loop_module_id = 1;
}

$td_module_class = td_api_module::_helper_get_module_class_from_loop_id($loop_module_id);

//disable the grid for some of the modules
$td_module = td_api_module::get_by_id($td_module_class);
if ($td_module['uses_columns'] === false) {
$td_template_layout->disable_output();
}

$args = array(
'post_type' => 'post',
'posts_per_page' => '30',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'alphabetical_letter',
'field' => 'term_id',
'terms' => array( '437' ), //this is by id
),
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array( 'muziek-recensies' ), //this is by slug
),
),

);

// The Query
query_posts( $args );

// The Loop

if (have_posts()) {
while ( have_posts() ) : the_post();
echo $td_template_layout->layout_open_element();

if (class_exists($td_module_class)) {
$td_mod = new $td_module_class($post);
echo $td_mod->render();
} else {
td_util::error(__FILE__, 'Missing module: ' . $td_module_class);
}

echo $td_template_layout->layout_close_element();
$td_template_layout->layout_next();
endwhile; //end loop
echo $td_template_layout->close_all_tags();

} else {
/**
* no posts to display. This function generates the __td('No posts to display').
* the text can be overwritten by the themplate using the global @see td_global::$custom_no_posts_message
*/

echo td_page_generator::no_posts();
}

this for the taxonomy-alphabetical_letter-n.php
<?php
/**
* the custom taxonomy template
* This file is loaded by WordPress on custom taxonomies. You can further customize this template
* for specific taxonomies by copying this file to taxonomy-yourTaxonomyName.php
*/

get_header();

global $loop_module_id, $loop_sidebar_position;

// get the current taxonomy object - note that it's note complete
$current_term_obj = get_queried_object();

//read the loop variables for this specific taxonomy
$loop_module_id = td_util::get_taxonomy_option($current_term_obj->taxonomy, 'tds_taxonomy_page_layout');
$loop_sidebar_position = td_util::get_taxonomy_option($current_term_obj->taxonomy, 'tds_taxonomy_sidebar_pos');

if (empty($loop_module_id)) {
$loop_module_id = 1; // module_1 is the default
}

// sidebar position used to align the breadcrumb on sidebar left + sidebar first on mobile issue
$td_sidebar_position = '';
if($loop_sidebar_position == 'sidebar_left') {
$td_sidebar_position = 'td-sidebar-left';
}

?>

<div class="td-main-content-wrap td-container-wrap">
<div class="td-container <?php echo $td_sidebar_position; ?>">
<div class="td-crumb-container">
<?php echo td_page_generator::get_taxonomy_breadcrumbs($current_term_obj); // get the breadcrumbs - /includes/wp_booster/td_page_generator.php ?>
</div>

<!-- content -->
<div class="td-pb-row">
<?php
switch ($loop_sidebar_position) {

default: //default: sidebar right
?>
<div class="td-pb-span8 td-main-content">
<div class="td-ss-main-content">
<div class="td-page-header">
<h1 class="entry-title td-page-title">
<span><?php echo $current_term_obj->name ?></span>
</h1>
</div>
<?php locate_template('loop-albumrecensies.php', true);?>
<?php echo td_page_generator::get_pagination(); ?>
</div>
</div>

<div class="td-pb-span4 td-main-sidebar">
<div class="td-ss-main-sidebar">
<?php get_sidebar(); ?>
</div>
</div>
<?php
break;

case 'sidebar_left':
?>
<div class="td-pb-span8 td-main-content <?php echo $td_sidebar_position ?>-content">
<div class="td-ss-main-content">
<div class="td-page-header">
<h1 class="entry-title td-page-title">
<span><?php echo $current_term_obj->name ?></span>
</h1>
</div>
<?php locate_template('loop-albumrecensies.php', true);?>
<?php echo td_page_generator::get_pagination(); ?>
</div>
</div>
<div class="td-pb-span4 td-main-sidebar">
<div class="td-ss-main-sidebar">
<?php get_sidebar(); ?>
</div>
</div>
<?php

break;

case 'no_sidebar':
?>
<div class="td-pb-span12 td-main-content">
<div class="td-ss-main-content">
<div class="td-page-header">
<h1 class="entry-title td-page-title">
<span><?php echo $current_term_obj->name ?></span>
</h1>
</div>
<?php locate_template('loop-albumrecensies.php', true);?>
<?php echo td_page_generator::get_pagination(); ?>
</div>
</div>
<?php
break;
}
?>
</div> <!-- /.td-pb-row -->
</div> <!-- /.td-container -->
</div> <!-- /.td-main-content-wrap -->

<?php

get_footer();

Post count: 101

Ok, solved it myself so nevermind.
Had set the number of post limit manually so it all got overridden.

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.