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 have created some custom fields with Advanced Custom Fields and set them to appear in my custom post type named X (post type is equal to X).

But I only need them to display on a particular single page from this custom post type, not on all of them.

How would I do that?

share|improve this question
    
So, really, this question doesn't specifically pertain to the ACF plugin, but rather to post custom meta data. You're essentially asking how to have certain custom meta data only appear on the edit page for a specific post. Question: how do/will you know which post you want to have display this custom meta data? –  Chip Bennett May 21 '12 at 14:15
add comment

1 Answer

up vote 1 down vote accepted

Couldn't you do this through ACF settings page? You can select Post and set it equal to the title.

Edit

Updated image for clarification

enter image description here

Edit 2

It turns out ACF does not query for custom type when display the title drop down. To include all post type, in /core/admin/meta_box_location.php, change

<div rel="post">
    <?php 

    $choices = array();
    foreach(get_posts(array('numberposts'=>'-1')) as $v)
    {
        $choices[$v->ID] = $v->post_title;
    }

    $this->create_field(array(
        'type'  =>  'select',
        'name'  =>  'location[rules]['.$k.'][value]',
        'value' =>  $rule['value'],
        'choices' => $choices,
    ));

    ?>
</div>

To

<div rel="post">
    <?php 

    $choices = array();
    foreach(get_posts(array('numberposts'=>'-1', 'post_type'=>'any')) as $v)
    {
        $choices[$v->ID] = $v->post_title;
    }

    $this->create_field(array(
        'type'  =>  'select',
        'name'  =>  'location[rules]['.$k.'][value]',
        'value' =>  $rule['value'],
        'choices' => $choices,
    ));

    ?>
</div>
share|improve this answer
    
That restricts it to post type, but the questioner wants to show it only on a single custom post type Post. Right now, there's no option for that. –  mrwweb May 18 '12 at 19:09
    
The question is "But I only need them to display on a particular single page". So if he only needs a single page, then he can pick exactly that page and do not need to worry about the type. Its like saying I want the Honda Civic who's license plate is 123455. I can just say the car with license plate 123455. –  ltfishie May 18 '12 at 21:25
    
@ltfishie, hang on, I meant a post, since this is a custom post type, My bad. However, it doesn't work either and there is apparently no way to only show these boxes I have created on just one post of a certain custom post type :/. –  Chris Demetriad May 21 '12 at 10:48
    
I updated the image. You can actually specify both post type and post name, and it worked for me. Match should be set to "All". Does that not work for you? Also, even if you don't select a post type and just specify the title, it should do what you needed. –  ltfishie May 21 '12 at 14:09
    
I can set it up like: post_type is equal to "xxx" where xxx is the name of my custom post type. But then, for the second condition, I don't see the name of my posts from that xxx custom post type, it would have been piece of cake. –  Chris Demetriad May 21 '12 at 15:17
show 3 more comments

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.