• Hey there,

    I have to:
    Display the content of special taxonomyzed page on the header, so outside of the loop.
    And… I can’t get it.

    Custom taxonomy is created with WCK (WordPress Creation Kit) plugin.

    Basicaly, on header.php:

    > Start the loop
    > Check if the page is special tax embeded
    > If, then display the_content() of the page here (the template page doesn’t embed the_content)
    > Stop the loop!

    Something like

    <?php
      global $post;
      $post_id = $post->ID;
      if ( is_tax('splash-arg','big-header' ) ) {
    
                       the_content();
    
     } else {
      }
    ?>

    OR, from codex

    <!-- Start the Loop. -->
     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
     <?php if ( is_tax('splash-arg','big-header' ) ): ?>
    
    <?php the_content(); ?>
    
     <?php else: ?>
    
     <?php endif; ?>

    OR

    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    
    <?php if (is_tax( 'big-header' )) :?>
    
    <?php the_content(); ?>
    
    <?php endwhile; ?>

    OR again

    <?php if ( has_term('splash-arg','big-header', $post->ID )) { ?>
    
    <?php the_content(); ?>
    
    <?php } ?>

    This is certainly a not so hard trick, but I’m not enought techy, so I’m sorry…

Viewing 1 replies (of 1 total)
  • Thread Starter 1bitor2

    (@1bitor2)

    RAHHHHH…
    I finaly got it, it work very well on the concerned page, BUT send an error message on all other pages.

    The snippet

    <?php
            if ( have_posts() ) : while ( have_posts() ) : the_post();
    
            // you can output your title, permalink, etc. anywhere within the loop
    
            // get all items in your custom taxonomy
            $terms = get_the_terms($post->ID, 'splash-arg');
    
            // loop through each term and perform your check
            foreach ( $terms as $term ) {
                if($term->name == 'big-header') {
                   the_content();
                }
    
            }
        endwhile; endif;
    ?>

    The error
    Warning: Invalid argument supplied for foreach() in blablabla/wp-header.php on line 37

Viewing 1 replies (of 1 total)
  • The topic ‘Show conditionnal taxonomy content outside the loop’ is closed to new replies.