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.

OK. I am reading this ACF tutorials, but I am not getting into this.

I have 2 post types: Lists and Contacts.

Every List must be related to some Contact, and I use Relationship custom field type (list_supplier), which is limited to only one choice (or Contact).

All I have to do is to display link on Lists template as Title of Contact post which is now related with that List.

Plugin
http://wordpress.org/plugins/advanced-custom-fields/

UPDATE:

OK. I am close to solve this, but I have some problems with filter.

Here is the code I am using in my template:

 <?php $contacts = get_field('list_supplier'); ?>
                    <?php if( $contacts ): ?>
                        <?php foreach( $contacts as $contact ): ?>
                            <a href="<?php echo get_permalink( $contact->ID ); ?>" target="blank"><?php echo get_the_title( $contact->ID ); ?></a>
                        <?php endforeach; ?>
                    <?php endif; ?>

In one moment I make it work on front end, but there was some problem with filters. When I add some of these filters into functions.php, choices from custom field list_supplier disappear. When I remove filter list_supplier chioces are there, but they are not showing on front end.

I know that problem is in filter, but I dont know how to wrote it.

share|improve this question
    
have you tried their example code? show us what code you have now. –  Milo Oct 14 '13 at 16:22
    
Hi @Milo. Sorry because of the delay. I was posting answer :) Unfortunately, I delete all my working code because I couldn't make it work. There was one interesting snippet... I will try to wrote it again. –  pendjer Oct 14 '13 at 16:50
    
@Milo, I just make it work :) I will post update... Thank you any way. Cheers! –  pendjer Oct 14 '13 at 17:06
    
@Milo, please can you take a look on my code now. I am realy close to solve this. I think that I have problem with filters. Thank you. –  pendjer Oct 15 '13 at 11:05
add comment

1 Answer 1

up vote 1 down vote accepted

Finaly, I make this working.

I put this in my template:

<?php $contacts = get_field('list_supplier'); ?>
<?php if( $contacts ): ?>
    <?php foreach( $contacts as $contact ): ?>
        <a href="<?php echo get_permalink( $contact->ID ); ?>" target="blank"><?php echo get_the_title( $contact->ID ); ?></a>
    <?php endforeach; ?>
<?php endif; ?>

And here is the filter I am using

<?php
function my_acf_load_field( $field )
{
    $field['choices'] = array(
        'custom' => 'My Custom Choice'
    );
    return $field;
}

// acf/load_field/key={$field_key} - filter for a specific field based on it's name
add_filter('acf/load_field/key=field_525c37d91ae8d', 'my_acf_load_field');
?>
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.