WordPress.org

Ready to get started?Download WordPress

Forums

Limit meta tags after each post (11 posts)

  1. Mezloh
    Member
    Posted 3 years ago #

    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

  2. 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.

  3. Mezloh
    Member
    Posted 3 years ago #

    "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?

  4. coopersita
    Member
    Posted 3 years ago #

    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;
    	}
    }
    ?>
  5. Mezloh
    Member
    Posted 3 years ago #

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

  6. Mezloh
    Member
    Posted 3 years ago #

    or is it in the functions file

  7. Mezloh
    Member
    Posted 3 years ago #

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

  8. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    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;
    	}
    }
  9. Mezloh
    Member
    Posted 3 years ago #

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

  10. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    make a backup copy of your existing template, and try it ;-)

  11. Mezloh
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic