Viewing 11 replies - 1 through 11 (of 11 total)
  • Wouldn’t you put the code in your template before the_content?

    From yoast’s example:

    <div id="yoast-taxonomy">
      <span class="taxonomy-people">
        People:
          <a href="https://example.com/people/joost/" rel="tag">Joost</a>,
          <a href="https://example.com/people/marieke/" rel="tag">Marieke</a>,
          <a href="https://example.com/people/tycho/" rel="tag">Tycho</a>
      </span>
    </div>
    <?php
    the_content('<p class="serif">Read the rest of this entry &raquo;</p>');
    ?>

    Thread Starter Raft

    (@raft)

    I just activated plugin and it appeared after the_content. And I need to put the 1st Slug before the_content, and the 2nd slug after it. Sorry for my English)

    Thread Starter Raft

    (@raft)

    I looked at the info but didn’t find the answer to my question

    Add this to your theme’s functions.php file:

    function show_taxonomies_here() {
    global $post;
    $opt  = get_option('yoast_simpletax');
    $output = '';
    foreach ( $opt['taxonomies'] as $taxonomy ) {
    $terms = get_the_term_list( $post->ID, $taxonomy['name'], $taxonomy['label'].':</dt><dd>', ',</dd><dd>', '</dd>' );
             if ($terms) {
                // For each taxonomy, create a dt wrapper (Definition Term)
                $output .= "\t".'<dt class="taxonomy-'.$taxonomy['name'].'">'.$terms."\n";
             }
    }
    echo '<dl class="yoast-taxonomy">'."\n".$output."\n".'</dl>';
    }

    Then put if(function_exists(show_taxonomies_here )) { show_taxonomies_here();} in your theme where you want it.

    Untested code, but it should work.

    Just wanted to state, for posterity, that katzwebdesign’s code works like a charm. Thank you ??

    are there any shortcodes available? i.e. I made the taxonomies: country,city,location and only want to display them underneath posts that actually deal with these things. so manually insertign a shortcode to display them woudl be great.

    if that is not possible, and I have ot go editing templates, what would be my best bet to only show them on specific posts?

    anyone? having shortcodes is so much greater than having to deal with templates per post ??

    Zack Katz

    (@katzwebdesign)

    If you want to make it a shortcode, add this to your functions.php instead:

    function simple_taxonomies_shortcode() {
    	return show_taxonomies_here();
    }
    add_shortcode('simpletax', 'simple_taxonomies_shortcode');
    
    function show_taxonomies_here() {
    global $post;
    $opt  = get_option('yoast_simpletax');
    $output = '';
    foreach ( $opt['taxonomies'] as $taxonomy ) {
    $terms = get_the_term_list( $post->ID, $taxonomy['name'], $taxonomy['label'].':</dt><dd>', ',</dd><dd>', '</dd>' );
             if ($terms) {
                // For each taxonomy, create a dt wrapper (Definition Term)
                $output .= "\t".'<dt class="taxonomy-'.$taxonomy['name'].'">'.$terms."\n";
             }
    }
    return '<dl class="yoast-taxonomy">'."\n".$output."\n".'</dl>';
    }

    Then you can use [simpletax] and have it show up wherever you want it inside a post.

    just brilliant ?? works perfect.

    just one last silly question:

    if I didn’t use this code, but the default plugin settings, and set it to auto append the taxonomies after the cotnent, would it always show them, whether I had taxonomies attached to a post or not?

    I notice this code only displays if there really are taxonomies attached to a certain post…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Simple Taxonomies – any place of the post’ is closed to new replies.