Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

topic

  • Solved

    Form submission saving as (no-name)

    When I fill out a form on the frontend then the data gets captures and I can view it from Frontend Admin for ACF > Submissions, however when I go to the custom posts it saves as (no-name) and the fields are all blank.

    I’ve setup

    • New Post Type: Cars
    • New Taxonomy: Brands

    Custom fields are:

    • Make
    • Model

    I’m fairly new to ACF so can someone advise as to what I’m doing wrong?

  • Solving

    Updating field values using the Javascript API

    Attempting to update some field values after taxonomy and post object selections have been made, but the simplest test of:
    acf.getField('custom_price').val(100);
    simply doesn’t work.
    I’ve also tried:
    acf.set('custom_price', 100);
    I’m unable to update any field values using the Javascript API.
    Any ideas?

  • Solved

    'Post Object' field, exclusion filter based on taxonomy?

    Hi folks …

    I have set up a custom field using the “Post Object” type. It’s only used in the back-end, on the post editor for the CPT in question.

    It is referencing the products in database (from Woocommerce). I have set up a filter to only include those items with publish post_status. For that I set up the following function:

    function cpt_review_product_filter( $args ) {
    	$args['post_status'] = array( 'publish' );
    	return $args;
    }
    add_filter( 'acf/fields/post_object/query/name=review_product', 'cpt_review_product_filter' );

    That worked fine. What I’d like to add to this filter is to exclude items that are in a specific category.

    I tried adding the following two (separately) lines, but neither worked. So I am obviously over-looking something.

    
        $args['term_id'] != '562' ;
        $args['product_cat'] != 'THE-CATEGORY-TO-EXCLUDE';
    

    My question …
    How can I filter out results that have a specific category assigned to them? (keeping in mind, these items are likely in numerous categories, but so long as one of their categories has ID 562 (in my case), I want to exclude it.

    Thanks very much …

    Jonathan

  • Solved

    Displaying an ACF image field for a Tag taxonomy within a loop of posts

    I have created an image field to be used with a tag by settings up the custom field to display in the backend if taxonomy = tag. I can add the image to the tag fine in the backend.
    The tags are set up and associated with individual custom posts (itineraries). I want to be able to display the image within a loop of the custom posts showing on a single.php page for another custom post type.

    The loop code to display the list of itineraries is:

    <?php
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    etc. etc.
    ?>

    Within this loop I am using the following code to display all tags associated with each itinerary in the list

    <?php
    // display tags and links for each post //
    $posttags = get_the_tags();
    if ($posttags) {
    echo”<ul class=’itinerary_tags’>”;
    foreach($posttags as $tag) {
    ?>

    <?php
    }
    ?>

    This give me a list of tags and links fine. HOwever I want to be able to display the image associates with each tag. Could anyone please help with the code needed to do this. Thanks

  • Solving

    Meta_query key for nested fields

    Hello,

    I do have a custom post type called products, that has a content build around repeaters. I have the following content construction:

    MAIN REPEATER (name: sales)
    field1: all_regions_name
    field2: all_regions_url
    field3: all_regions_date_start
    field4: all_regions_date_end
    nested repeater (name: different_regions)
    field1: name
    field2: url
    field3: date_start
    field4: date_end

    Based on that I want to build a WP_Query that displays only posts which based on current date:
    A. is included in the range FROM all_regions_date_start TO all_regions_date_end OR
    B. is included in the range from nested repeater date_start TO date_end

    I have added this code:

    
    function sales_replace_repeater_field( $where ) {
         $where = str_replace( "meta_key = 'sales_$", "meta_key LIKE 'sales_%", $where );
         return $where;
    }
    add_filter( 'posts_where', 'sales_replace_repeater_field' );

    and this one:

    
    function diff_replace_repeater_field( $where ) {
         $where = str_replace( "meta_key = 'different_regions_$", "meta_key LIKE 'different_regions_%", $where );
         return $where;
    }
    add_filter( 'posts_where', 'diff_replace_repeater_field' );

    Here are my loop args:

    
    $today = date('Ymd');
     $sales_query = new WP_Query( array(
            'post_type' => 'products',
    		'meta_query'=> array(
    			'relation' => 'AND',
    			array(
    			  'key' => 'sales_$_all_regions_start_date',
    			  'compare' => '<=',
    			  'value' => $today
    			),
    			array(
    			  'key' => 'sales_$_all_regions_end_date',
    			  'compare' => '>=',
    			  'value' => $today
    			)
    		),
            'tax_query' => array(
                array(
                    'taxonomy' => 'category',
                    'field' => 'slug',
                    'terms' => array( $sales_product->slug ),
                    'operator' => 'IN'
                )
            )
        ) );

    But I’ve stucked. I have no idea, how to add there condition/meta_query key for the second (nested) repeater.

    How to achieve that? What is then a key for that nested repeater? Because both:
    – different_regions_$_start_date
    – different_regions_$_end_date

    Doesn’t work.. Thanks!!

  • Helping

    Search field finds nothing

    Hello,

    I have a little problem. I wanted to create a custom field for a taxonomy where a user can select a post. So I set the custom field to Post Object.

    However, when I edit the taxonomy, the search box won’t find anything. No matter what I enter, even when I just click it.

    I was able to track it down to the search box itself. I’ve tried a different type, for example field type “Taxonomy” for categories. A simple checkbox will display me all my categories. But when I change it to Multi Select, I get the same search box and still no results.

    I am not sure if that is a bug or if I am missing something.

    Help is appreciated 🙂

    Thanks!

  • Unread

    The ACF field does not work properly with Redis Cache

    Description:

    I have one ACF image field where the condition is Taxonomy - is equal - Category (product_cat)

    In the front-end, I display this field as follows:
    get_field('woo_img', $category->taxonomy . '_' . $category->term_id)
    and I make its visibility dependent on the $_GET parameter

    Up to this point, everything works fine. The image displays correctly where it needs it

    Issue:

    After enabling Redis Object Cache unfortunately the image stops displaying on the front-end

    Does ACF work with Redis? Have I done something wrong?

  • Unread

    How to get current edited taxonomy term ID with acf/render_field?

    Hi,

    I’m adding some custom content to a taxonomy term field with acf/render_field, but I can’t figure out how to get the current term ID when using this action.
    get_queried_object() returns null.

    To clarify this is the location I’m at /wp-admin/term.php?taxonomy=tax_name&tag_ID=123

  • Helping

    Update field in category by functions.php on category save?

    I’have some problem with my WordPress functions.php script.

    When I go to edit Category of Post, I have URL:

    /wp-admin/term.php?taxonomy=category&tag_ID=3&post_type=post&wp_http_referer=%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dcategory

    I need a function to update the field in category with ID from URL.

    function overwrite_ratings_category(){
    	update_field('field_630dbc7cf3fdd', '432', 'category_'.$_GET['tag_ID']);
    }
    
    add_action('edit_term','overwrite_ratings_category');

    When I use number (e.g. 3) instead $_GET[‘tag_ID’] function works fine. But it’s not working with $_GET[‘tag_ID’].

    Is there any other way to get the ID of the currently edited category?

  • Helping

    Taxonomy attached to another taxonomy

    A bit confusing I know but anyway let me try to define the problem… )) A marketplace site has a custom post type ‘company’ for listing suppliers. They ‘company’ post type has attached custom taxonomies called ‘product-categories’ and ‘product-brands’. I can list the terms of these taxonomies so that users can find necessary suppliers based on product categories or brands or both.

    I also would like to link the two taxonomies together, i.e. each ‘brand’ has ‘product categories’ attached so that each brand term indicates which product category it belongs to. I did it by adding a custom field to the ‘brand’ taxonomy and attaching the ‘product category’ to that field. Now I can display the product categories for each brand on its term page.

    However, the other way around turns out to be more difficult. When I try to indicate what brands are associated with a given product category, I cannot find a solution. I need to list ‘brand’ taxonomy terms that are attached to a given ‘product category’ taxonomy term.

    Or let me reword this in ACF terms. ) How I can get all taxonomy terms that have a specific value in one of their custom fields? I can’t use wp_query as I’m not looking to find posts but taxonomy terms. Tried wp_get_object_terms, for some reason it did not work.

  • Solving

    Search in 3 different custom posts using 3 diferent custom fields

    Hello, I have this 3 custom posts that I want to search and filter, so far I have not found a good way to search.

    event
    -band (relationship, created using ACF)
    -place (relationship, created using ACF)

    band
    -music_type(custom taxonomy, similar to posts categories, created using CTP UI)

    place
    -location (Radio Button, created using ACF, list of places)

    Now, I would like to search all the events of a location and of a music_type.

    Is this possible?

    Maybe I’m doing something wrong or in the free version of ACF this is not an available functionality.

  • Unread

    Query ACF Fields in RestAPI GET

    Dear ACF Community,

    I want to query some posts with ACF fields which have a specific content.
    The GET Query is working fine to get all posts of a type and also query for standard fields like title, slug, status is no problem. Also REST-API is enabled for the taxonomy and post-type.

    Doing the query for

    {
    "acf": {
    "brand": "Example"
    }
    }

    either in
    Body, Header or Query with GET Request is only giving all posts from that type.

    Would be really nice to find a solution for this.

  • Solving

    strategy for replacing Text Field with Taxonomy term value selection?

    Hi,

    I’ve taken over a site where our client administrators are having to type the name of a taxomony term value into a text field on a custom post

    Unfortunately it’s likely that they misspell or use other versions of the correct value

    It should really be a drop down taxonomy term selector .. ie ACF field type = Taxonomy.

    let’s say the field is called subject and one of the values is “Book Shop”, sometimes this might be added as eg “Bookshop” or “Book-shop” and this is breaking some of the template logic

    There are 1000+ existing records and I could do a search & replace, but again it should really just be a select box based on the Taxonomy Terms

    however if I change the field type to correct this for future posts, it’s going to break the old posts

    What would be the best strategy for fixing this going forward whilst dealing with the old data?

    I don’t preferably want to change it to a normal select box with fixed values (so it stores as a single string in the db anyway as per https://support.advancedcustomfields.com/forums/topic/change-type-of-field-from-text-to-select/)…

    Really I want it as a term value selector so any changes to the actual original Taxomomy Term are actually directly updated via the reference

    However these field types are therefore incompatible.

    Can I for instance create a new field with the same name (again let’s say subject) but a different type… and then adjust my logic to account for the old text versions and the new term value reference versions? (and if old posts are updated it will overwrite with the new value?)

    Or would it be better to create an entirely new field with a different name going forward and then adjust the template to check for both (prioritising the new one first)

    thanks for any suggestions
    J

  • Unread

    Relationship field and auto selecting all posts based on taxonomy

    Hello

    I need help with a relationship field and I am honestly not sure if this was done correctly.

    Currently there are 2 cpt, a Solutions (5 main categories) and a Services with Taxonomy (Service Groups).

    Currently in the backend, when I go to a Solutions page, I can filter by taxonomy to see what services are available and to make it easier to select the services.

    Is there a way to make it so that if I select say Taxonomy B, it’ll auto select all services and add to the right without having to click on each individual service to add?

  • Helping

    Taxonomy field not updating db nor behaving as intended

    When using the taxonomy field for a custom block (in combination with a custom taxonomy), if you add a term to that field and save it – then it saves no problem. If you remove it again, it doesn’t remove it.

    In addition the ‘save terms’ and ‘load terms’ options do not work at all. As such the field works in isolation to the pages actual taxonomy.

  • Solved

    Sort post by acf date first and after by title

    Hello everybody,
    I have an issue on a website.
    I need to display movies (my custom post: ‘films’) and some have a release date (ACF field : ‘date_de_sortie’) and others do not have one.
    I would like to display in first movies with release date (from the the closer to the further ) and only after, those which don’t have a release date (ordered by title).

    For now it displays in first movies without a release date in and after those with a release date, order is ok.
    Here is my function :

    
    add_action( 'pre_get_posts', 'films_query' );
    function films_query( $query ) {
    if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'films' ) ) {
    $cat_hide = get_field('categorie_des_films_a_masquer', 'options');
    $taxquery = array(
    array(
    'taxonomy' => 'categorie_films',
    'field' => 'term_id',
    'terms'    => $cat_hide,
    'operator' => 'NOT IN',
    )
    );
    $query->set( 'posts_per_page', '-1' );
    $query->set( 'post_status', 'publish' );
    
    $query->set( 'meta_key', 'date_de_sortie' );
    $query->set( 'orderby', 'meta_value title' );
    $query->set( 'order', 'ASC' );
    
    $query->set( 'tax_query', $taxquery );
    }
    }
    

    Do I need to use $query->set( ‘meta_query’, $meta_query ); with $meta_query args ?
    Any help appreciated.
    All the best.
    Pierre

  • Unread

    Taxonomy Description on Single Post Type

    Hello!
    I’m having trouble with something and I wonder if you could help me, or point me in the right direction.

    I have a custom post type named ‘Projects’, where I display all my latest projects.
    Then, I also have a custom taxonomy associated to that which is called ‘Project Types’ (for example: Copywriting, Research, Methods). This essentially works as a category.

    What I’m wanting to do is write a description for each of my Project Types and have it pull through on the Single Project page (for the Projects that have that specific Project Type associated to it). So that I only need to update the description once and it will automatically update on all the relevant Project pages.

    What I’m wanting to avoid is having to edit the description on each single project page as they’ll be over 100!

    I am also using Elementor, if that makes things easier!

  • Helping

    Close to what I need, but just missing the mark

    I’m trying to make a Dynamic Gallery in WordPress. I can almost get there with ACF. I can create a Gallery in ACF, link it within Elementor, set it up to only show images uploaded to the current post, but the problem is that I need to select the images from my Media Gallery… Meaning it’s not Dynamic. I don’t want to do that otherwise I’m just using the same set of images all over the site (or on pages that I choose). I’m trying to add a condition that will show certain images in the Media Gallery based on their Taxonomy. How do I set this up with ACF?

  • Solving

    ACF uses wrong language while creating a term when Polylang is enabled

    Hi! I’ve found a bug in ACF Pro in combination with using Polylang. Don’t know if you want to support Polylang, but is seems like an easy fix.

    When creating a new term using the Taxonomy field type (with the ‘+’ button), ACF will use the default site language to create the term, and not the language from the current post you are editing.

    If you save the post after creating the term, the created term will not be visible in the Taxonomy field, unless I change its language manually to the language the post is in.

  • Solving

    Query Sorting By Taxonomy Name Pulled From Subfield

    Been bashing away at this for hours with no joy.

    I have a set of custom fields in a repeater on posts in the “episodes” category.

    https://www.dropbox.com/s/g0vxzk2mg9q31f3/acfquery.png?dl=0

    I’m trying to do a query that outputs those custom fields and sorts them alphabetically by the name of the “episode_canon_show” custom field which uses the post_tag taxonomy.

    The output is no problem but I can’t get the sorting to take hold. I’ve scoured the forums but I didn’t see anything that matched what I am doing. Thank you!

  • Helping

    Order ACF taxonomy terms by user's current distance from location

    Hi,

    I built a web app where users are workers and building sites are taxonomies, each term having a single ACF Google Maps field to save site’s latitude and longitude.
    I made it possible to workers to edit their own working days entries, using acf_form() in front end, letting them choose the day’s building site from a dropdown managed by ACF taxonomy field.

    Using Geolocation_API I’d like to order the dropdown list by the current user’s distance from each site, ordering building sites by the nearest to the farthest.

    Because user’s location is a temporary value by definition, I’m struggling to get how to compare the ACF stored building sites coordinates values with the user’s lat+long and return a ordered by distance terms list on the front end drop down.

    Using ACF taxonomy query filters I can get into the query I need, as per documentation:

    add_filter('acf/fields/taxonomy/query', 'my_acf_fields_taxonomy_query', 10, 3);
    function my_acf_fields_taxonomy_query( $args, $field, $post_id ) {
    
        // Show 40 terms per AJAX call.
        $args['number'] = 40;
    
        // Order by most used.
        $args['orderby'] = 'count';
        $args['order'] = 'DESC';
    
        return $args;
    }

    As long as I already have each building site latitude and longitude, and the current user’s coordinates as well, I suppose I need to use usort() function to change the OrderBy output.

    Is this the right solution and could anyone suggest me the right sintax to obtain something like:

    $args[‘orderby’] = “my_usort_result()”;

    Thanks!

  • Solved

    Copy Tags From Custom Field To Native Tags?

    On the left is a podcast topic rundown created in ACF where shows discussed are added from the native tags taxonomy. Is it possible to have these selections added to the native post tag list as seen on the right? Possibly on save or using some wizard magic?

    https://www.dropbox.com/s/ct4k9xz2190wbya/acf.png

  • Unread

    Get response location acf

    Good afternoon,

    I want to know if it’s possible for me to get the answer from the location of an acf, example
    by Taxonomy, and print those taxonomies inside the Query using:

    acf/fields/taxonomy/query

    The idea is when I click on a taxonomy, it shows exactly that taxonomy in the query

    Because i need get taxonomy, when his choice inside post admin.

  • Unread

    Taxonomy Field "plus" button missing on mobile

    I created something for the user to upload info from a mobile device. However the PLUS button to add taxonomies is missing on mobile Safari. I figured out how to make it visible all the time on desktop with the code below, but it’s still missing on mobile.

    add_action(‘admin_head’, ‘show_plus’);

    function show_plus() {
    echo ‘<style>
    .acf-actions.-hover
    {
    display:inline-block !important;
    }
    </style>’;
    }

  • Solving

    how to set up radio button get value from taxonomy

    this is my step
    1. i have post type stories and i create a new taxonomy(type of chapter) for stories
    2. i add new value in this taxonomy (text, video, cartoon image)
    this is my issue
    after add new value i do not know how to sync value to your radio field for categorize my posts according to a given taxonomy.

    can you help me?

Viewing 25 results - 251 through 275 (of 3,191 total)