• Resolved The_Gray_Wolf

    (@the_gray_wolf)


    Hi,

    My custom post type is named “tutorijal” and my custom taxnomy “serija”. I want to display only the tutorials (tutorijal) from the current serie (serija), so for example if the user is on the website-name/tutorials/xhtml-and-css, only to display posts belonging to category xhtml-and-css.

    here’s my code from my taxonomy-serija.php :

    <?php get_header(); ?>
        <div class="container">
          <div class="row">
            <div class="col-md-12">
    			<?php
    			$post_type = 'tutorijal';
    			$tax = $wp_query->get_queried_object();
    			$tax_terms = get_terms($tax);
    			if ($tax_terms)
    			{
    				foreach ($tax_terms  as $tax_term)
    				{
    					$args=array(
    				    'post_type' => $post_type,
    					"$tax" => $tax->slug,
    					'post_status' => 'publish',
    					'posts_per_page' => -1,
    					'ignore_sticky_posts'=> 1
    								);
    				$my_query = null;
    				$my_query = new WP_Query($args);
    				if( $my_query->have_posts() )
    				{
    					echo '<ol>';
    					while ($my_query->have_posts()) : $my_query->the_post(); ?>
    					<li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    				<?php
    				endwhile;
    				echo '</ol>';
    				}
    				wp_reset_query();
    				}
    			}
    			?>
            </div>
          </div>
    <?php get_footer(); ?>

    I var_dumped the $tax_terms and it gives me an error that goes like this : object(WP_Error)#304 (2) { [“errors”:”WP_Error”:private]=> array(1) { [“invalid_taxonomy”]=> array(1) { [0]=> string(16) “Invalid taxonomy” } } [“error_data”:”WP_Error”:private]=> array(o) { } }

    Any help?

    Thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Error with displaying posts within a custom taxonomy’ is closed to new replies.