• Could someone please let me know what to add here in order to limit the amount of meta tags that show up after a post. exp: 7 tags

    <?php if(function_exists('the_tags')) {$my_tags = get_the_tags();if ( $my_tags != "" ){ the_tags('Tags: ', ', ', '<br />'); } else {echo "Tags: None";} }?>

    I looked at the codex pages but couldn’t put it together as easy as it may be.

    Or if this needs to be changed elsewhere please point me in the right direction.

    thank you

Viewing 10 replies - 1 through 10 (of 10 total)
  • Here are some suggestions: https://www.ads-software.com/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.

    Thread Starter Mezloh

    (@sayno2odor)

    “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;
    	}
    }
    ?>
    Thread Starter Mezloh

    (@sayno2odor)

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

    Thread Starter Mezloh

    (@sayno2odor)

    or is it in the functions file

    Thread Starter Mezloh

    (@sayno2odor)

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

    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;
    	}
    }
    Thread Starter Mezloh

    (@sayno2odor)

    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 />');

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

    Thread Starter Mezloh

    (@sayno2odor)

    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.