• Resolved rstackj

    (@rstackj)


    Hey guys,

    Is there a way to add a category dropdown to let users directly select the fitting category?

    Same with the featured image. As I can not restrict the file types that can be uploaded to the featured image with the standard functionality of this plugin, is there any way to use a custom acf file upload field and set this as the featured image?

    Thanks for your assistance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Shabti Kaplan

    (@shabti)

    Yes

    Create an ACF field, choose type = taxonomy, taxonomy = category, turn on the save terms and load terms settings, and add it to your form. Then create an image field and turn on the set as featured image setting and add it to your form

    Thread Starter rstackj

    (@rstackj)

    Thanks Shabti!

    While this works to some extends it doesn’t fully fit my needs.
    For example I can’t restrict the categories (there are some I dont want users to be able to add a post to).

    I guess there’s no premade solution for that?

    Thanks for your assistance!

    • This reply was modified 6 years ago by rstackj.
    Plugin Author Shabti Kaplan

    (@shabti)

    For the dropdown, set Appearance to “multi select”

    To restrict categories, Here is a piece of code you can drop into your functions.php in your child theme. In this example I am showing only categories who’s parent category has the ID of 18:

    add_filter('acf/fields/taxonomy/query/name=name_of_your_field', 'restrict_field_taxonomy_query', 10, 3);
    function restrict_field_taxonomy_query( $args, $field, $post_id ) {
    
        $args[ 'parent' ] = 18;
    
        // Order by most used.
        $args[ 'include' ] = [ 18 ];
       
        return $args;
    }
    Thread Starter rstackj

    (@rstackj)

    Work’s flawlessly.

    Thank’s for providing this kind of support in your free time!

    • This reply was modified 6 years ago by rstackj.
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Adding category selection’ is closed to new replies.