WordPress.org

Ready to get started?Download WordPress

Forums

Name Tag on Post Title (10 posts)

  1. webbando
    Member
    Posted 3 years ago #

    Hi guys,

    Do you know if is it possible add the name of the tag in the post title?

  2. webbando
    Member
    Posted 3 years ago #

    Someone can help me?

    Thanks a lot

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

    can you elaborate on your question?
    example for instance?

    do you mean: tag as in taxonomy?

  4. webbando
    Member
    Posted 3 years ago #

    Example:

    I have a post with title:"Good life" which has one tag:"Past"

    I want that the tag title will be:"Past: Good life", is it possible?

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

    instead of
    <?php the_title(); ?>

    you could try and use:

    <?php $posttags = get_the_tags();
    if ($posttags) {
    foreach($posttags as $tag) {
    echo $tag->name . ': '; break;
    }
     } ; the_title();  ?>
  6. webbando
    Member
    Posted 3 years ago #

    Doens't work...

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

    the code needs to be in the loop.

    what in particular does not work?
    can you post the inserted new code with a few lines before and after ?
    or link?

  8. webbando
    Member
    Posted 3 years ago #

    What i want is to insert the title in tag title of the header, not title in loop...

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

    small adaptation - check for single post, and use the post id in 'get_the_tags()':

    <?php if(is_single()) { $posttags = get_the_tags($post->ID);
    if ($posttags) {
    foreach($posttags as $tag) {
    echo $tag->name . ': '; break;
    }
     } ; the_title(); } ?>
  10. webbando
    Member
    Posted 3 years ago #

    Doens't work... :(
    Edit: it works but not with plugin "all in seo pack"

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags