Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using Gravity Forms to allow users to create posts from the front end.

However, the way this site I am building is going to work, one specific Post_Type is essentially just a "Data" post. There is a specific Taxonomy who's Terms are actually the "Title" of the data set.

I have already figured out a way to hide the "Title" field in Gravity forms but still have it present on the form (for some reason they lock the "Post_Type" and "Post Status" into the 'Title' field in the GUI, so I overloaded it's conditional logic to force it to always hide).

I want to create a filter that would always copy the [Term] value for a specific [Taxonomy] into the [Title] field of a specific [Post_Type].

Any advice I could get on how to accomplish this would be great! Thanks in advance!

==============================================================

OK, using code from @Manny Fleurmond below, and from this post: Title_save_pre - Simple problem that u know for sure

I came up with

function taxonomy_title_rename($title) {
    global $post;
    $type = get_post_type($post->ID);
    if ($type== 'CUSTOM_POST_TYPE') {
            if($post->post_type === 'CUSTOM_POST_TYPE') {
        $terms = wp_get_object_terms($post->ID, 'MY_TAXONOMY');
        if(!is_wp_error($terms) && !empty($terms)) {
            $title = $terms[0]->name;
        }
        }
    return $title;
}
     else if ($type != 'CUSTOM_POST_TYPE') {
       return $title;
    }
    }
    add_filter ('title_save_pre','taxonomy_title_rename');

This is actually saving the post title to the post from the taxonomy. However, it is not then pulling it into the permalink as well, my permalink is just the post ID number. Will see if I can get this solved on my own, but any help would be appreciated!

share|improve this question
    
Hrm.... something in the same realm of this unanswered question perhaps: wordpress.stackexchange.com/questions/15800/… –  Duiwel Jul 10 '11 at 5:29
add comment

2 Answers

I've pieced together a solution. Let me know if it's what you need:

add_filter('the_title','term_filter',10,2);
function term_filter($title, $post) {
    $post = get_post($post) ;
    if($post->post_type === 'special_post_type') {
        $terms = wp_get_object_terms($post->ID, 'taxonomy');
        if(!is_wp_error($terms) && !empty($terms)) {
            $title = $terms[0]->name;
        }
    }
    return $title;
}

Basically, I'm using a filter for the title that checks what post type the title is from. If it is the correct type, the title is replaced by the first term of your taxonomy that is connected to that post.

Ask me any questions if something isn't clear!

share|improve this answer
    
Hey man, thanks for taking the time to take a stab at this for me! This is Close, but it seems to just be masking the Title... only in the back-end list for posts does it show the converted title, when one goes to edit the post, the post is still definitely named "Untitled" and the permalink is also "/untitled". But ya definitely did something close to what I'm going for, it just seems to be a mask instead of an actual change. –  Duiwel Jul 10 '11 at 15:34
    
I updated my top post with a fix I came up with using some of your code, but came up with a new problem as well! Thanks for the help. –  Duiwel Jul 10 '11 at 22:17
add comment
up vote 0 down vote accepted

Well, since I essentially came up with my own answer using what was posted (which didn't really work) plus some extra research, I am going to close this question, even though I sort of added an additional question;

OK, using code from @Manny Fleurmond below, and from this post: Title_save_pre - Simple problem that u know for sure

I came up with

function taxonomy_title_rename($title) {
    global $post;
    $type = get_post_type($post->ID);
    if ($type== 'CUSTOM_POST_TYPE') {
            if($post->post_type === 'CUSTOM_POST_TYPE') {
        $terms = wp_get_object_terms($post->ID, 'MY_TAXONOMY');
        if(!is_wp_error($terms) && !empty($terms)) {
            $title = $terms[0]->name;
        }
        }
    return $title;
}
     else if ($type != 'CUSTOM_POST_TYPE') {
       return $title;
    }
    }
    add_filter ('title_save_pre','taxonomy_title_rename');

This is actually saving the post title to the post from the taxonomy.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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