Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have been using this plugin so users can in a controlled manner upload their own posts, now it has a category dropdown and I wanted a set list for a tag dropdown where another user kindly helped me out.

The problem I have now is that the tags show as the ID number instead of the name itself.

Example of the post: http://wordpress.art-williams.com/countries/testing-dropdown-tags-21 (it shows 120, experiences at the bottom when it should say "Hotel for example)

I am a novice at wordpress but I can copy + paste :/

The add destination page is here if you need to see it: http://wordpress.art-williams.com/add-destination

Any help is hugely appreciated! I just dont know how to fix that. Here is the code for the tags by the way.

<!-- START TAGS -->
  <?php
    if($this->ucan_options['uCan_Allow_Tags'])
    {
  ?>
      <label>
        <?php echo __('Your Experience', 'ucan-post'); ?>:
        <span class="small"><?php echo __('(What was your travels purpose?)', 'ucan-post'); ?></span>
      </label>


        <?php 


        wp_dropdown_categories(array('taxonomy'=> 'post_tag','exclude'=>6,129,'hide_empty' => 0, 'name' => 'ucan_submission_tags'));
        ?>


  <?php
    }
  ?>
  <!-- END TAGS  -->
share|improve this question
Experiences is tag too, but it displays slug as you want, so as @Colin said be sure that slug for 120 is set right – Mamaduka Aug 26 '11 at 18:19
I had a check and the slug's are the correct to the tags name, but when made a post using that tag it creates another tag of the ID, really weird. So I select "hotel" and it makes a tag "120" – Art Aug 26 '11 at 18:38
What plugin do you use? – Mamaduka Aug 26 '11 at 18:45
Its called ucan post, it seams quite indepth. If it helps I can let you in the ftp or something? – Art Aug 26 '11 at 18:59

closed as too localized by toscho Jul 10 '12 at 21:38

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

2 Answers

To fix the issue, you will need to further alter the plugin. If that works for you, read on.

The wp_dropdown_categories function you are using passes tags via their ID. The plugin requires the values to be in the form of slug. Here is a fix that converts the tag ID to slug.

Replace the following line in ucan-post-class.php:

line 369:   $ucan_new_post['tags_input'] = $this->ucan_options['uCan_Default_Tags'].', '.stripslashes($_POST['ucan_submission_tags']);

With:

$tag = get_term(stripslashes($_POST['ucan_submission_tags']), 'post_tag');
$ucan_new_post['tags_input'] = $this->ucan_options['uCan_Default_Tags'].', ' . $tag->slug;

Keep in mind, this will only allow users to add one tag for each post.

share|improve this answer
Well the ID of the tag is 120, but I just assumed it would use the name of it. When I publish the post, the tag 120 is then created so thats odd. I will update that excludes thanks for that! – Art Aug 26 '11 at 18:34
I have checked the slug and they are correct. So the tag: Hotel has the slug: hotel, and when I publish a post using the tag "Hotel" it will create this new tag as "120" its really weird :/ – Art Aug 26 '11 at 18:37
Can you post your code used to generate the post. It sounds like there is an issue when writing to the database. – Colin Morgan Aug 26 '11 at 19:32
Ok here is the plugin post-class.php pastebin.com/Qi29L9J0 and here is the plugins submission form, where the elements are you see on add-destination page: pastebin.com/gKybRAFj – Art Aug 26 '11 at 19:39
Can you confirm if it is occurring for more than just that tag? Also, can you check if there are any default tags set in the admin options panel. – Colin Morgan Aug 26 '11 at 20:21
show 2 more comments

It will take some modification but recently I tried using post_category as one of the arguments for wp_insert_post but every attempt ran unsuccessfully, or made the category a number. This is what I used instead (after the new post is inserted and the ID of the new post is valid in a variable).

if( $insert_post ) {
    wp_set_object_terms( $insert_post, intval( $insert_post['post_category'] ), 'category');
}

Where $insert_post was the same type of array the plugin in question is using in uCan_Display_Publish(). I was only using one category, so I think if you want to do multiple categories, you should use intval() on each item in the post_category array.

In your case, it would most likely be after if ($new_post_id) {

Hope this points you in the right direction!

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.