WordPress.org

Support

Support » How-To and Troubleshooting » Limit meta tags after each post

Limit meta tags after each post

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator Kathryn

    @zoonini

    Automattic Happiness Engineer

    Here are some suggestions: http://wordpress.org/support/topic/how-to-limit-tags-returned-by-the_tags?replies=7

    By the way, WordPress post tags and meta tags are two completely different things.

    “post” meta tags, “post” tags they are both the same to me. If that makes it any better. But thanks for the suggestion. However, I do know the difference between what you are implying.

    I already looked at the post you suggested 3 times didn’t help each time HAHA!

    Which is my reason for pasting in the code so if someone that can help they can re-paste the code with a suggested fix.

    Or do I need to change the parameters in one of the include files?

    anyone?

    As the post zoonin suggested:

    <?php
    $posttags = get_the_tags();
    $count=0;
    if ($posttags) {
    	foreach($posttags as $tag) {
    		$count++;
    		echo '<a href="'.get_tag_link($tag->term_id).'">'.$tag->name.'</a> ';
    		if( $count >4 ) break;
    	}
    }
    ?>

    Change it to (notice the 7):

    <?php
    $posttags = get_the_tags();
    $count=0;
    if ($posttags) {
    	foreach($posttags as $tag) {
    		$count++;
    		echo '<a href="'.get_tag_link($tag->term_id).'">'.$tag->name.'</a> ';
    		if( $count >7 ) break;
    	}
    }
    ?>

    Coopersita, Ok, I see that. What include file is that in.

    or is it in the functions file

    Am i looking at WP files or theme files to change this?

    Moderator Michael

    @alchymyth

    Forum Moderator

    the suggested code is supposed to more-or-less replace this section of your posted code:
    the_tags('Tags: ', ', ', '<br />');

    a few small tweaks; this should do:

    $posttags = get_the_tags();
    $count=0; $sep='';
    if ($posttags) {
    echo 'Tags; ';
    	foreach($posttags as $tag) {
    		$count++;
    		echo $sep . '<a href="'.get_tag_link($tag->term_id).'">'.$tag->name.'</a>';
    $sep = ', ';
    		if( $count >7 ) break;
    	}
    }

    I got you now. I have been pullin out the hair that i have left looking all over for this code. Thanks

    so you are saying to overwrite this section of code?

    the_tags('Tags: ', ', ', '<br />');

    Moderator Michael

    @alchymyth

    Forum Moderator

    make a backup copy of your existing template, and try it 😉

    Of course I will make a backup. Thanks for the help.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Limit meta tags after each post’ is closed to new replies.