Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

reply

  • Yes, it is a User field. We’re getting tripped up by some confusing terminology. I said “Relational” because the User field type is one of several fields (Page Link, Post Object, Relationship, Taxonomy, User) listed under the “Relational” category. I hope that clarifies things.

  • @hube2 Thanks once again for your help, but I have noticed another ‘bug’ the Wysiwyg Editor fields don’t seem to be displaying content with paragraph tags anymore either with the activation of the filter plugin.

    I currently have the call looking like this …

    the_field(‘column_1′, $term);

    // $term = $taxonomy.’_’.$term_id to get the correct category content

    I found this http://goo.gl/Y8Jw5E and tried reversing it like this …

    the_field(‘column_1’, true, true, $term);

    But that broke it πŸ™

    but I tried this and it worked …

    $wysiwyg = get_field('column_1', $term);
    echo apply_filters('the_content', $wysiwyg);

    I hope this may help others in the future.

  • here is the code I use

    if(function_exists(“register_field_group”))
    {
    register_field_group(array (
    ‘id’ => ‘acf_categories-settings’,
    ‘title’ => ‘Categories settings’,
    ‘fields’ => array (
    array (
    ‘key’ => ‘field_55cd9d1bdb108’,
    ‘label’ => ‘Featured Image’,
    ‘name’ => ‘categories_featured_image’,
    ‘type’ => ‘image’,
    ‘save_format’ => ‘object’,
    ‘preview_size’ => ‘header’,
    ‘library’ => ‘all’,
    ),
    ),
    ‘location’ => array (
    array (
    array (
    ‘param’ => ‘ef_taxonomy’,
    ‘operator’ => ‘==’,
    ‘value’ => ‘category’,
    ‘order_no’ => 0,
    ‘group_no’ => 0,
    ),
    ),
    ),
    ‘options’ => array (
    ‘position’ => ‘normal’,
    ‘layout’ => ‘default’,
    ‘hide_on_screen’ => array (
    ),
    ),
    ‘menu_order’ => 0,
    ));
    }

  • So I kind of simplified how I’m displaying these on the front end. In actuality, it’s displaying in three select fields, with each taxonomy in it’s own field, and then some jQuery to show and hide different fields based on the user’s selection of Make.

    Honestly I did think about doing it that way, but I didn’t want me client to be able to set up levels deeper than needed (for example, if I made it hierarchical, they could set up Honda > Civic > Accord > Fit > Element, and just keep going down).

    Maybe I’ll just switch to hierarchical if this can’t be easily done; I can always just warn my client that making deeper levels of makes/models could break things.

  • Hi @william-alexander

    Well first of your client is an idiot but fine! πŸ˜‰

    The attributes in WooCommerce is saved as an multidimensional array in the wp_postmeta table and looks like this:

    
    array (
      'testattribute' => 
      array (
        'name' => 'testattribute',
        'value' => 'attributevalue',
        'position' => '0',
        'is_visible' => 1,
        'is_variation' => 0,
        'is_taxonomy' => 0,
      ),
    )
    

    So you would have to try to replicate that using your own custom fields.
    I think it might be possible to do using nested repeater fields but you’ll not really end up with an easier way of input and the client wont be able to just hit “save attributes” but would have to update the whole product post each time they alter an attribute.

    Really you should tell your client you can attempt to do your own solution but will have to add x hours to the invoice (probably atleast 4-5h) and in the end the solution might not be easier than the default. There’s a reason why WooCommerce have it as it is and they have multiple devs working SOLELY on optimising every aspect of WooCommerce and millions of users liking it as it is.

    It all comes down to my first reaction, your client is an idiot πŸ˜‰

  • Hi @revxx14

    Not that I want to be “that guy” but why don’t you just use a single hierarchal taxonomy for both make and model?

    That way your interactions with it in code will be very simple and as an added bonus you’ll be able to get sweet URL structures like /make/honda/civic/.

  • @bknightly i cant say how to use it with ID,
    but i can show you how to use a size, when you do it with array (3 option beside id and url)

    $items = wp_get_nav_menu_items('menu_name'); //replace menu_name with menu-name, menu-id, menu-slug (menu-location is not valid!)
    foreach((array) $items as $key => $item) {
    	$taxonomy = $item->object;
    	$term_id = $item->object_id;
    	$url = $item->url;
    	$title = $item->title;
    	$image_url= get_field('icoon', $taxonomy._.$term_id); //replace "icoon" with the fieldname you give to the image
    	echo '<li><a href="'.$url.'" title="'.$title.'"><img src="'.$image_url[sizes][large].'" /></a></li>'; //replace large with size you wish
    }
    

    hope that help nevertheless

    just if someone is interested, i use this for build a taxonomy menu with images:

    <?php
    get_header();
    // to build a menu with image and name from a Taxonomy i use this (inside my archive-CPT.php):
    //this values you need to adjust: 
    //my_taxonomy => slug of taxonomy (3x)
    //my_taxonomy_image => name of imagefield at taxonomy page (1x)
    //teaser_thumbnail => image size
    $terms = get_terms("my_taxonomy", array(
        'hide_empty' => 0
    ));
    $count = count($terms);
    if ( $count > 0 ){
        foreach ( $terms as $term ) {
        $permalink = get_term_link( $term->slug , 'my_taxonomy');
        	$output .=  '<div class="taxonomy_menu_item"><a href='.$permalink.' titel="'.$term->name.'">';
            
            $my_taxonomy_teaserimage = get_field('my_taxonomy_image', 'my_taxonomy_'.$term->term_id);
            $size_taxonomy_teaserimage = 'teaser_thumbnail';
    	$taxonomy_teaserimage = $my_taxonomy_teaserimage['sizes'][ $size_taxonomy_teaserimage ];
    	$width_taxonomy_teaserimage = $my_taxonomy_teaserimage['sizes'][ $size_taxonomy_teaserimage . '-width' ];
    	$height_taxonomy_teaserimage = $my_taxonomy_teaserimage['sizes'][ $size_taxonomy_teaserimage . '-height' ];
    	
    	$output .=  '<img alt="'. $term->description .'" src="'. $taxonomy_teaserimage .'" width="'.$width_taxonomy_teaserimage.'" height="'.$height_taxonomy_teaserimage.'" />';
    	$output .=   '<h3>'.$term->name.'</h3>';
    	$output .=  '</a></div>';
         }
    }
    echo $output;
    get_footer();
    ?>
  • Hi Elliot / ACF Forums,

    I’m having an issue getting a feature to work with ACF on a site I’m currently building. I’m using WP v4.2.4 and ACF v4.4.2.

    Specifically, I’m trying to display images associated with Taxonomy Terms in pages using wp_get_nav_menu_items and the Menus feature in the WP Dashboard, inspired by @zcdb and his provided code. His example which works perfectly with “Image URL” selected in my custom field, but doesn’t work when I select “Image ID”. I want to display images using “Image ID” instead of “Image URL” so I can designate a smaller image size to display instead of the full size image that is currently being output.

    I’ve looked through ACF’s documentation, and have been able to successfully display images using the “Basic display (ID)” technique, but after several hours of testing and scouring the forums I’m at a loss on how to do the same with @zcdb’s example.

    Is there a way to achieve the result I’m after?

    Thanks in advance for any advice you can offer!

  • Solved it with a filter.

    add_filter('acf/fields/taxonomy/wp_list_categories', 'my_taxonomy_args', 10, 2);
    
    function my_taxonomy_args( $args, $field )
    {
       $args['exclude'] = array(16, 15, 17); //the IDs of the excluded terms
        return $args;
    }
  • The only way to really do what you want is to use a custom taxonomy. WP does not have the ability to create archive pages based on a custom field. See my answer to this recent question for more information. http://support.advancedcustomfields.com/forums/topic/linking-custom-fields-tag-or-archive-layout/

    Also, check out these two pages I found on the subject
    http://wordpress.stackexchange.com/questions/2545/show-links-to-archive-pages-based-on-custom-field-values
    https://wordpress.org/support/topic/how-can-i-create-an-archive-by-custom-field

    and do a search for wordpress archive page based on custom field

    What you’re looking to do would be the same with or without ACF, it’s just something that WP doesn’t do easily.

  • Yes, you could map a custom field to a tag, you could create an acf/save_post filter outlined here http://www.advancedcustomfields.com/resources/acfsave_post/, get the field value and then add the term to the post using wp_set_post_terms(). This is essentially what ACF does for a taxonomy field. If I were setting this up I would more than likely use a custom taxonomy called “Country”, this is a perfect example of were it would be a good choice.

  • Thanks John.

    I found 2 things in my search just now:

    1. ACF 4 – Meta rule plugin works well https://wordpress.org/plugins/advanced-custom-fields-meta-location-rule/

    2. ACF 5 – Like John said:
    – I made a taxonomy called “template”
    – and taxonomy field that updates the post terms on each page
    – then “post taxonomy” is equal to “template type” on template field groups

    Works like a charm!

  • You can’t set location rules base on a select field in another field group.

    but you can use a custom taxonomy, you could call it “Page Type”. This would work just like a “Category” for Posts and you can have the field groups locations set based on the taxonomy terms.

  • What appear when you click on the Filter by Taxonomy field when setting up the page link field? Anything at all? This may be caused by a JavaScript error.

    can you post a screen shot of what you’re seeing in the ACF field group editor or the field?

  • This will not be easy to achieve in WordPress. What you’re talking about doing is created custom search to search a custom field, but instead of a form to have urls for each custom field value. While not impossible to do on your own, you’d be better off finding an existing search plugin that will let you do it.

    quick search
    https://www.google.com/search?q=wordpress+search+custom+fields&ie=utf-8&oe=utf-8

    If you want to be able to do this on your own I’d suggest using a custom taxonomy rather that a custom field. With a custom taxonomy you can create an archive page in WP the includes a standard WP URL to display the archive for each value.

  • As far as I know there aren’t any tools in existence that will let you import the ACF custom fields attached to a taxonomy/term. This would probably be something that would need to be custom built for the job.

  • For anyone that’s following or finds this.

    ACF 5 Pro allows terms to be added on the front end. The user must be logged in and have the capability to add terms to the taxonomy. You might even be able to do this with by setting the right capabilities when setting up the custom taxonomy. You’d need to look into the WP docs for that.

  • Hi Jonathan, Sorry for being unclear. I had to check the “art” checkbox in the Wp Catagories box (in addition to selecting the “art” taxonomy in the ACF Taxonomy select box).

    Daniel

  • Hi Daniel,

    Glad I could help. By check off do you mean that you had to uncheck the “art” category in the builtin category-taxonomy for your custom taxonomys term “art” to work properly?

  • Hi Jonathan,

    You identified the problem exactly. I did not register the custom taxonomy in functions.php. If you had not told me how to do this and provided the snipped I would be lost, so thank you very much.

    I would like to point out that to make the archive work for the custom posts types (with the custom Taxonomy) I had to select the correct Taxonomy in the custom Taxonomy selection box and ALSO check off the identical Category Taxonomy in the standard WP Catagories box. I am totally ok with this, but want to point it out to check and make sure this is ok and won’t bite me down the road.

    Thank you for your help!
    Daniel

  • Hi @jma

    This isn’t really an issue of ACF and something that is beyond what ACF does and should do.

    However I have written a plugin myself which is available for free on wordpress.org which does pretty much exactly what you want. It requires price and model to be taxonomies tho, not meta fields.
    https://wordpress.org/plugins/beautiful-taxonomy-filters/

  • Hi @donad

    So have you set the taxonomy to display as a column on the “all cpt” list?
    Are the terms created and exists properly otherwise when you check the taxonomys admin panel?

  • Solved enabling options Save/Load terms and hiding metabox with:

    function hide_metabox_tax() {
    	remove_meta_box( 'taxonomynamediv' , 'cpt' , 'normal' );
    }
    add_action( 'admin_menu' , 'hide_metabox_tax' );
  • Hi @dniclas

    You say you’ve also registered a custom taxonomy connected with your portfolio-cpt but to me it seems you’ve rather created a term/category named art only. That means that when visiting the archive you’re visiting the archive of a regular category (wordpress builtin categories).

    If you want to only display your custom post type you’ll have to hook into the query for this archive and change the post_type OR actually register your own taxonomy and use that instead.

    Here’s a snippet you can add to your themes functions.php to change the archive of the specific “art” category to only display your CPT:

    
    function my_modify_queries( $query ) {
    	
    	//dont run on admin or not a main query
        if ( is_admin() || ! $query->is_main_query() )
            return;
    
        if ( is_category('art') ) {
            // Display only 1 post for the original blog archive
            $query->set( 'post_type', 'portfolio-cpt' );
            return;
        }
    
    }
    add_action( 'pre_get_posts', 'my_modify_queries', 1 );
    
  • I’d like to use Taxonomy field in place of the default wordpress meta box, but at the same time I’d like that the Taxonomy field could be integrated with the WP backend. Is it possible?

    Plaese, let me know, it’s urgent for a client project.

Viewing 25 results - 2,426 through 2,450 (of 3,193 total)