WordPress.org

Ready to get started?Download WordPress

Forums

Batch Add Taxonomies to Specific Posts (8 posts)

  1. eddai
    Member
    Posted 4 years ago #

    I'm running a movie related site. I use taxonomies to categorize movies into Actors, Directors, Year, Genre etc..

    For years, I use exact year like 2009, 2010.. But now I also want to add year spans by adding taxonomies like 2000's, 1990's etc..

    Is there an easy way to do add for every 2001, 2002, ..... , 2009 years an extra taxonomy of 2000's ?

    Maybe can be done via sql ?
    Can anyone help me ?

    I hope my question is clear.. Thanks

  2. keesiemeijer
    moderator
    Posted 4 years ago #

    What do you use to show the taxonomies? wp_list_categories()?

  3. eddai
    Member
    Posted 4 years ago #

    I'm using <?php echo get_the_term_list( $post->ID, 'tur', '', ', ', '' ); ?>

    not using categories, I use taxonomies..

  4. keesiemeijer
    moderator
    Posted 4 years ago #

    Put this inside the loop:

    <?php
      // Get terms for post
      $terms = get_the_terms( $post->ID , 'tur' );
      if (!empty($terms)){
      $html='';
      // Loop over each item
        foreach( $terms as $term ) {
          $html .= '<a href="' . get_tag_link($term->term_id) . '" rel="tag">' . $term->name . "'s" .'</a>';
        }
      echo $html;
      }
    ?>
  5. eddai
    Member
    Posted 4 years ago #

    hi keesiemeijer, thanks for response,
    but don't we have to run sql query ?

    my purpose is to add an "extra" taxonomy to default ones..

    lets say

    Movie Title: Gladiator
    Year: 2000

    Movie Title: Avatar
    Year: 2009

    my purpose is to add one more taxonomy as 2000's to all posts belong to 2000-2009, so

    Movie Title: Gladiator
    Year: 2000, 2000's

    Movie Title: Avatar
    Year: 2009, 2000's

    but there are hunders of titles to add taxonomies.. so I'm looking for an easy way if possible..

    thanks

  6. keesiemeijer
    moderator
    Posted 4 years ago #

    Maybe I don't understand, but can't you then just give your posts an extra custom "tur" taxonemy tag "2000's".

  7. eddai
    Member
    Posted 4 years ago #

    for new entries yes, I can easily add..
    but I already had posted over 600 entries.. that is why I'm looking for an easy way to batch add taxonomies..

    thanks for taking your time, much appreciated.

  8. keesiemeijer
    moderator
    Posted 4 years ago #

    Ah yes, then you need to run a sql query or customize the functions that the wordpress core uses to insert tags in the database. That is a bit over my head. sorry

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags