WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to remove posts tags in bulk (15 posts)

  1. AtaArticles
    Member
    Posted 3 years ago #

    ataarticles.com

    I have removed unused tags using wp plugin but i have some posts in excess of 12 plus tags which i want to reduce to 3 max.

    Is this possible or do i need to manually go through each post which would take weeks as there are about 50000 plus posts. But not all are with tags.

    It seems you can only remove tags with zero count. But is it possible to remove tags in bulk without deleting the posts

  2. MichaelH
    Member
    Posted 3 years ago #

    You can delete tags even when assigned to a post and the post does not get deleted.

    Easy to test that.

    Write a post, add a new tag. Then go delete that tag.

  3. AtaArticles
    Member
    Posted 3 years ago #

    Ok,

    Not sure how i can delete tags with published post.

    I tried as you suggested and created 'test' post with tag as 'Entertainment'.

    http://www.ataarticles.com/business/test/

    Now how do i delete all the post tags without deleting all the posts?

  4. MichaelH
    Member
    Posted 3 years ago #

    Goto the Post Tags menu item and delete the tag(s) there.

    Administration > Posts > Post Tags

  5. AtaArticles
    Member
    Posted 3 years ago #

    Hi

    I was aware of the post tags before but i assume it would delete the post aswell. But it seems to work, thanks.

    Now how can i limit users to 3 tags per post when they try to publish their articles again?

    Do i need to look in loop.php but there is also tag.php aswell.

    Thanks.

  6. MichaelH
    Member
    Posted 3 years ago #

    Not sure but you'd need to look at wp_insert_post that uses wp_set_post_tags that uses wp_set_object_terms.

  7. AtaArticles
    Member
    Posted 3 years ago #

    Hello,

    What i find rather strange is neither single.php (post template) or tag.php has the word 'tag' in it.

    Hence trying to search for wp_set_post_tags is futile.

    Now with loop.php i found 5 tags. But referring to the code below you can see it doesn't have wp_set_post_tags

    -----------------------------------------------------

    <?php
    $tags_list = get_the_tag_list( '', ', ' );
    if ( $tags_list ):
    ?>
    <span class="tag-links">
    <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
    </span>

    --------------------------------------------------

    If this is not possible, how can i hide the tags from published post.
    On each post on my site the 'Twenty Ten' template seems to show all the tags below post. I tried to delete some coding from above but didn't seem to work.

  8. MichaelH
    Member
    Posted 3 years ago #

    One possible solution for in the loop:

    <?php
    $taxonomy = 'post_tag';
    $args='';
      $terms = wp_get_post_terms($post->ID , $taxonomy, $args);
      if ($terms) {
        $count = 0;
        foreach ( $terms as $term ) {
          $count++;
          if ($count <= 3) {
            echo '<p><a href="' . esc_attr(get_term_link($term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a> has ' . $term->count . ' post(s). </p> ';
          }
        }
      }
    ?>
  9. AtaArticles
    Member
    Posted 3 years ago #

    Hi,

    Did you mean replace the code with your the taxonomy code or to embed below it?

    I tried replacing the code, but the post tags still show but when you click on the tags it gives error message:

    Parse error: syntax error, unexpected T_ENDIF in /home/ata/public_html/wp-content/themes/twentyten/loop.php on line 174

    http://www.ataarticles.com/tag/skin-care/

  10. MichaelH
    Member
    Posted 3 years ago #

    Didn't test this but you'd probably replace this code in loop.php of that theme with the code I listed:

    <?php
    					$tags_list = get_the_tag_list( '', ', ' );
    					if ( $tags_list ):
    				?>
    					<span class="tag-links">
    						<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
    					</span>
    					<span class="meta-sep">|</span>
    				<?php endif; ?>
  11. AtaArticles
    Member
    Posted 3 years ago #

    Hi,

    I replaced the new code aswell but similar error:

    Parse error: syntax error, unexpected T_ENDIF in /home/ata/public_html/wp-content/themes/twentyten/loop.php on line 178

  12. AtaArticles
    Member
    Posted 3 years ago #

    I mean replaced the code you listed before and same errors.

  13. MichaelH
    Member
    Posted 3 years ago #

    I'll let you play with the formatting, but just to give you an idea here's the loop.php I'm using:

    http://wordpress.pastebin.com/P3ETS3Te

  14. AtaArticles
    Member
    Posted 3 years ago #

    Ok, will study that code and see if it works out.

    Thanks for your help.

  15. AtaArticles
    Member
    Posted 3 years ago #

    Ok, i found a nice little plugin which deletes all tags and works great:

    http://blogpig.com/products/nukepig

    Did the job in a few seconds.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags