Support

Account

Home Forums Backend Issues (wp-admin) Location Rules – Media library Audio files only

Solving

Location Rules – Media library Audio files only

  • Hi Elliot

    Tried to set up a filter where I can display a field set only when editing an audio file in the Media Library (as opposed to pdfs, images etc)

    I looked at your documentation and found the page “Custom location rules” – managed to sort the “Add Custom Field Types” by adding the following code to the site’s functions file

    add_filter('acf/location/rule_types', 'acf_location_rules_types');
    function acf_location_rules_types( $choices )
    {
        $choices['Other']['media'] = 'media';
    
    	return $choices;
    }

    However when trying to edit your example of the “Add Custom Values” I changed your example to the following:

    add_filter('acf/location/rule_values/media', 'acf_location_rules_values_media');
    function acf_location_rules_values_media( $choices )
    {
        $media = get_media();
     
        if( $media )
        {
            foreach( $media as $media )
            {
                $choices[ $media->data->ID ] = $media->data->display_name;
            }
        }
     
        return $choices;
    }

    I had to guess a lot of it and it came back saying “Parse error: syntax error, unexpected T_VARIABLE in /data04/records/public_html/wp-content/themes/Futureproof/functions.php on line 37”

    Would appreciate if you tell me what this piece of code should be. I’m looking to display a field set only when editing an audio file in the Media Library and not when bringing up pdfs, images and other media types.

    Trying to pre-empt the future. I’ve looked at the section “Matching the rule” and not really understood it in terms of the context I’m looking to use this (i.e. showing the field set only when looking at MP3/audio files via the Media library) Therefore please could you also advise how your code for “Matching the Rule” should be edited for my request to work.

    I know a little about php but my knowledge base can be sketchy

    Many thanks

    Phil

  • Hi Elliot

    Posted this around 2 weeks ago – was wondering if you could get back to me on it or let me know if there’s an issue?

    Many thanks

    Phil

  • OMG – What’s happening – I’m tearing my hair out here. Have I done something wrong, pissed someone off or something.

    I posted my original question to this string a while back thinking it was a reasonable question to ask, but having received excellent support/help on previous posts, I don’t seem to be getting any response. Maybe I was lucky on previous occasions when I seemed to receive help/support 24hrs later without fail.

    Have just spent 4 hours going through the forums/documentation to see if I can solve my issue but haven’t really got anywhere.

    Maybe Elliot’s on holiday or something?

    If I have annoyed someone or am not doing something correctly in my post I’d really appreciate if someone could please tell me or point me towards what I have done wrong & how to move forward.

    Many thanks in advance to anyone who can help me

    Phil

  • Hi Elliot

    I asked the above question about custom location rules relating to media types back in May but was unable to get any help to resolve the issue.

    It’s now six months on and i really need to get this sorted. Is there a way I can pay for support to get this issue resolved? Please can you let me know as I’m six month behind in getting this project up and running.

    I look forward to hearing from you about this matter

    Many thanks

    Phil

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Location Rules – Media library Audio files only’ is closed to new replies.