Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

topic

  • Solving

    Woo Commerce Banner Image

    Please Help, I’ve created an archive-product.php and in it I have my,
    <?php woocommerce_content();?>

    In the global-top-banner above this, I have my usual php code to call in my theme banner image (using my usual ACF image ID). Works perfectly on all other, page.php, single.php, category.php, etc…

    The button to add the picture is showing on the backend on the Store page as its seeing my ACF rule to add to all default pages, and I can obviously select the image I’d like to choose from the media library here.

    However I can not find any ACF selector to display the image on this Store page??

    I’ve tried trying to add a;

    Template Name: Woo Page – but that doesn’t work – as it doesn’t appear on the Store (backend) to select.

    I’ve read that… even though this Store appears as a page it gets converted to a ‘Special Archive’ but I can’t tap into this using Taxonomy = Category or Taxonomy = Prod_Category…

    How do I get this image to show on this page please…

    (archive-product.php code below)

    <!– Main –>
    <main>

    <!– Top Banner –>
    <div class=”thin-top-banner”>
    <?php get_template_part(‘top-banners/global’,’top-banner’);?>
    </div>

    <!– Section One | Centered Content –>
    <section class=”centered-content”>
    <div class=”woo-content-container”>
    <?php woocommerce_content();?>
    </div>
    </section>

    </main>

  • Helping

    Don't recive taxonomy title

    Hi, i have form to add new taxonomy and i also need template with form for editing this taxonomy so have for editing taxonomy next form but problem is that i get all value for custom field but for title of taxonomy i didnt get.

    <?php acf_form(array(
        'post_id' => $_GET["post"],
        'post_title'	=> true,
        'field_groups' => array(
            'group_5f475552ca375'
         ),
        'submit_value'		=> 'Shrani',
        'html_submit_button'	=> '<input type="submit" class="acf-button btn btn-primary" value="%s" />',
        'uploader' => 'wp',
        )); 
    ?>

    $_GET[“post”] i get from url parameter and the post title input is vissible but it is empty

  • Solving

    Convert an ACF field to taxonomy

    My client has thousands of custom posts and wants to categorize them using custom field values.

    For example, he wants to categorize students according to the state. And there is already a field named state. Is there a way we can use that field to add each custom post into State taxonomy? Otherwise, it’ll take weeks to do it manually.

  • Helping

    Taxonomy with subcategories

    Hey im trying to display a taxonomy field and i would like to only show my parent categories and not the subcategories.
    Im using acf_form heres my code:

    
    $settings = array(
    	'post_id'       => 'new_post',
    	'new_post'      => array(
    		'post_type'     => 'contrats',
    		'post_status'   => 'pending'
    	),
    	'post_title'  => true,
    	'submit_value'  => 'Nouveau contrat créé !',
    	'submit_value' => __("PUBLIER"),
    	'field_groups' => array(27)
    );
    acf_form($settings);
    

    And here a screenshot:

  • Helping

    WP_Query using ACF Taxonomy Category

    I’m trying to create a WP_Query loop with a custom post type of project and using ACF Taxonomy field to filter just those categories. I found in this forum an example, but it’s not working.

    plus I think I need to add something for if there is only 1 category selected rather than multiple.

    The loop is working without the taxonomy arg. I think I’m pretty close, but nothing shows when I add in the taxonomy arg.

    here is what I have:

    
    // this field can return either a single category or multiple
    $categories = get_field('project_slider_category');
    if ($categories) {
      if (!is_array($categories)) {
        $categories = array($categories);
      }
    }
    
    $args = array(  
        'post_type' => 'project',
        'post_status' => 'publish',
        'posts_per_page' => 8, 
        'orderby' => 'title', 
        'order' => 'ASC',
        'tax_query' => array(
          array(
            'taxonomy' => 'categories',
            'terms' => $categories,
          ),
        ), 
    );
    
    $loop = new WP_Query( $args );
    

    I attached a screenshots with my ACF settings and showing what is selected in my example.

  • Solved

    create new taxonomy with acf form not new post

    Hi i want to save a new taxonomy, but i cant get the form to frontend.
    Custom field are sucess visible in backend but on frontend i cant see, i think becuse i dont have right code. My custom taxonomy name is “narocilnice” and code is:

    <?php acf_form(array(
        'id' => 'acf-form',
        'post_id' => true,
        'post_title'	=> true,
        'new_post'		=> array(
            'tax_name'		=> 'narocilnice',
        ),
        'submit_value'		=> 'Shrani',
        'html_submit_button'	=> '<input type="submit" class="acf-button btn btn-primary" value="%s" />',
        'uploader' => 'wp'
        )); 
    ?>

    On this picture printscreen you can see that i get on backend custom field but on frontend i can’t. So i need add new taxonomy to custom taxonomy name “narocilnice” not new post to custom post_type.

    Can someone tell me what is wrong?

  • Solving

    Taxonomy field by ids and wp_query

    I am having a brain fart on an issue that I’ve done many times before…

    I’ve made an Ad system using a CPT instead of an Options page…
    Each ad post has ACF that controls it fully and I have a section that allows the user to select and assign the taxonomies to each ad so that I will know on which post taxonomies to place the ads… I need the taxonomies field to return “IDS” instead of OBJECTS…
    So my field returns as an array:

    Array ( [0] => 452 [1] => 506 [2] => 464 [3] => 472 [4] => 456 [5] => 744 [6] => 745 [7] => 428 [8] => 689 [9] => 681 [10] => 603 [11] => 606 [12] => 683 [13] => 639 [14] => 615 [15] => 601 [16] => 628 [17] => 621 [18] => 609 [19] => 552 [20] => 476 [21] => 740 [22] => 480 [23] => 447 [24] => 416 [25] => 453 [26] => 449 [27] => 550 ) 1

    I just need to assign a certain ID to the query below. The issue is that I am ONLY ABLE TO Assign 1 which works… But I need multiple. What am I doing wrong?

    Ive tried this which doesn’t work:

        'meta_query' => array(
            array(
                'key' => 'assign_to_taxonomies',
                'value' => array ( '689', '452', '744' ),
                'compare' => 'IN'
            )

    My working code is below:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
    $args = array(
      'post_type' => array('click_ads'), 
      'meta_query' => array(
          'relation' => 'AND',
    
        array(
              'key'     => 'select_ad_location', 
              'value'   => 'side', 
              'compare' => '=', 
              'type'    => 'CHAR', 
          ),
       
        
         array(
             'key'     => 'assign_to_taxonomies', 
             'value'   => serialize( strval('689') ),  //1 ID assign. but need multiple
             'compare' => 'LIKE', 
            'type'    => 'CHAR',
          ),
          
    
      ),
      'post_status' => 'publish', 
      'order' => 'DESC', 
      'orderby' => 'date', 
      'posts_per_page' => 1,
      'paged' => $paged, 
    );
    
    // WP_Query
    $eq_query = new WP_Query( $args );
    if ($eq_query->have_posts()) : // The Loop
    $eq_count = 0;
    ?>
    <div class="">
    
    <?php 
    while ($eq_query->have_posts()): $eq_query->the_post();
    $eq_count++;
    ?>
    
    <div class="ad-layout ad-cta">
        <div class="adtype"><?php the_field('enter_ad_code'); ?></div>
        <span class="adv align-center">ADVERTISMENT</span>
    </div>
    <?php endwhile; wp_reset_query(); ?> 
    </div>
    
    <?php endif;
  • Helping

    Taxonomy field not saving data?

    I’ve created a taxonomy in CPT UI. Then I created a taxonomy field in my ACF field group with that taxonomy. The values come up, and I can save them with my CPT, but my actual taxonomy counts are at 0. Like ACF is saving the taxonomy as meta data instead of updating the taxonomy table. Any idea what I might be doing wrong?

  • Helping

    Edit taxonomy term in frontend form?

    Hello,
    i am trying to edit a taxonomy term in frontend form, anything is correclty show (acf group) but the title. Title field is empty but i pass post_title to true..
    These are my args (i need form arg to be false):

    
    $options = array
    (
    'form'            => false,
    'post_id'         => 'term_' . $pid,
    'post_title'      => true,
    'field_groups'    => array(18),
    'label_placement' => 'top',
    'submit_value'    => 'Salva',
    'return'          => add_query_arg(array('a' => 'edit', 'notice' => 'added'), get_permalink())
    );

    Someone acn help me to pass the correct args? Or maybe is a bug/limitation?

    Thanks

  • Unread

    Filtering Custom Taxonomy on Forms, retrieving additional data on Front End

    Apologies if this has been asked before, but I’m a little new to working with ACF at code level and can’t find a solution to my current challenge. Right now I’m working on a WP plugin that will allow site owners to make notes against simple projects via a custom post type (bl-project-log) and a custom taxonomy (bl-project). The project taxonomy basically works like standard categories and has been extended via custom fields to track start date (bl-project-start) end date (bl-project-end) and a few other bits of meta not relevant to this example. Just like categories I’m able to list the custom taxonomy on the front end and on forms, but I want to customise this a little:

    1. Front end: filter out projects which don’t have an end date, order by start date, not by name. I can do this in JS and CSS, but it’s inelegant and doesn’t scale well.
    2. Back end: when creating a new bl-project-log I only want to see projects which don’t have an end date, i.e. those that are still open. Right now I see all projects in this custom taxonomy but again it doesn’t scale well since I’m reusing project names and adding dates to the name in order to differentiate them, so filtering by bl-project-end would be ideal.

    Many thanks in advance for assistance – really appreciate this!

  • Helping

    Custom loop in ACF block

    Hello,

    I’m creating a block to display a “workshop” custom post type
    Each post has a date custom field and I would like to sort them by date

    But I can’t get the value of the field in the block render template with a regular WP loop… I tried a query_post and it’s working but then I can’t sort the results by the date field 🙁

    here is my code so far, what am I missing… I guess I have to make a second loop to get the post by my date custom field… but can’t find out how!

    					<?php
    						$num = get_field('number');
    						$cat = get_field('cat');
    						//$date = get_field('date');
    						
    						if ($num) {
    							$number = $num;
    						} else {
    							$number = '-1';
    						}
    						
    						// if ($date) {
    						// 	$key = 'date';
    						// 	$by = 'meta_value';
    						// } else {
    						// 	$key = null;
    						// 	$by = null;
    						// }
    						
    						$args = array(
    							'posts_per_page' 	=> $number,
    							'post_type' 		=> 'product',
    							//'meta_key'			=> $key,
    							//'orderby'			=> $by,
    							'order'				=> 'DESC',
    							'tax_query' => array(
    								array(
    									'taxonomy' => 'product_cat',
    									'terms' => $cat,
    									'field' => 'slug',
    								),
    							),
    						);
    						//$products = new WP_Query($args);
    						$products = query_posts($args);
    						
    						foreach ($products as $p) : 
    						
    							$date = get_field('date', $p->ID);
    							
    					?>
    						<div class="product-block">
    							
    							<div class="product-figure">
    								<?php echo get_the_post_thumbnail($p->ID, 'screen-md' ); ?>
    							</div>
    							<p class="product-title h3-like"><?php echo get_the_title($p->ID); ?></p>
    							<p><?php echo $date; ?></p>
    							
    						</div>						
    							
    					<?php 
    						endforeach;
    						wp_reset_postdata();
    					?>	
  • Unread

    How to get User Role specific fields?

    Hi all,

    I created a field for Subscriber user role. But I can’t get it to show in front end. I tried the following:

    acf_form_head();
    get_field('sample');

    sample is a taxonomy. I want to show user specific fields.

    Can somebody help me with this?

    Regards

  • Solved

    Get field on index outside loop

    Hello! First of all, sorry me for my bad English but isn’t my native language. I’m having a problem with a field not showing up on index.php of my site. I’ve a group of fields applied to post_tag taxonomy, and want to show the field av_slider (the URL of a image field) on index.php outside the loop.

    The code I’ve right now is:

    <?php $tags = get_tags(array(
    'number'=> 3,
    'orderby'=> 'count', 
    'order'=> 'ASC',));
    $html = "<ul class='av-grid'>";
    foreach ( $tags as $tag ) {
        $tag_link = get_tag_link( $tag->term_id );
                 
        $html .= "<li style='background: url(". the_field('av_slider', $tag->term_id) .") no-repeat center; background-size: cover;'><a href='{$tag_link}' title='{$tag->name}'><div class='av-grid-title'>";
        $html .= "{$tag->name}</div><span class='av-grid-icon av-icon-eye'></span></a></li>";
    }
    $html .= "</ul>";
    echo $html; ?>

    The problem is the_field(av_slider) is blank and can’t get it to display the image url.

    Thanks a lot in advance! 🙂

  • Solving

    Displaying field with get_terms

    Hi

    I have a custom taxonomy with a custom field called thumbnail_image

    I want to create a page that lists all the taxonomies with a link, title and image. I can get it to display the term and link but when I try to add the ACF field I am having problems.

    <?php 
    					$terms = get_terms(
    						array(
    							'taxonomy'   => 'species',
    							'hide_empty' => false,
    						)
    					);					
    					if ( ! empty( $terms ) && is_array( $terms ) ) { ?>
    					<ul>					
    					<?php						
    					foreach ( $terms as $term ) { 
    						?>
    						<li>
    							<a href="<?php echo esc_url( get_term_link( $term ) ) ?>">						
    							<?php echo get_field('thumbnail_image', 'species_' . $term->term_id ) ?>		
    							<?php echo $term->name; ?>
    							</a>
    						</li>
    						<?php }	?>
    					</ul>
    				<?php } ?>

    I have tried

    $image = get_field('thumbnail_image', 'species_' . $term->term_id );
    and
    $image = get_field('thumbnail_image', $term);
    with
    <?php echo $image ?>

    and still the same problem.

    It just displays array. The PHP error is

    Notice: Array to string conversion in

  • Unread

    problem with save taxonomy from front end form

    when i save taxonomy in custom field(and i select save terms) and create a new post via front end form the post not retrive the taxonomy, if i go in the post and click on update the taxonomy appear correct

  • Solved

    Select posts and terms on ACF field

    I’m building a page where I go to manually retrieve posts through ACF’s “Post Object” field.
    I would need to be able to broaden the range of action of this field, allowing you to also choose individual taxonomies terms.
    There is a special “Taxonomies” field but I need to be able to choose between both types (post and taxonomy term).

    Anyone have any suggestions?

  • Solving

    Fix ACF Gallery and back-end

    Good morning all ,

    I came here to share my attempt to fix a big mobile acf issue

    I’m doing a basic and simple project, a real estate website
    nothing fancy just an image gallery, posts with descriptions, lists and search filters. I know elementor builder will take care of all of this. Thank goodness there are options for responsive modes, so good. I can drink my coffee, water my flowers and feed the cats.

    after the break, it’s time to install acf pro in the back-end acf takes care of menus and options and lots of nice fields,
    the sun is coming back, perfect! it’s time to save and see the result. like everyone else, I’m happy on the desktop, everything is fine .. or almost (we’ll see why)

    then came the inevitable moment to test acf on mobile, of course the “mobile first” rule is important. even in the back-end. This is when things went horribly wrong …

    i took a look at the docs and forum to see if i can do anything to fix this .. nothing.

    so I grabbed my adobe xd I reproduced the ACF display on mobile pixel by pixel to illustrate the problem and the solutions

    to be sure that this is not a problem coming from me, I did two clean installs with the latest wp and acf pro. the problems are still there (in fact they have been there for as long as I can remember back to 2019 ..)

    to reproduce these bugs, just create different fields and try to use them in mobile mode there are probably many others that I have not yet tested

    let’s try to correct and dive into details

    -First detail, gallery field, a visual disaster, on mobile it only works once then it freezes, cannot open a photo, scroll or open the sidebar again. I tried to correct the display, but the bug that frezze is beyond me.

    fix gallery

    -Second detail, the display of dropwdown (taxonomy and select), the (+) add, the differences in colors, heights, font and padding, invisible scrollbar, I tried to correct all this to make them consistent and less disturbing in mobile, and I also prevent the auto focus keyboard on search.

    fix dropdown

    function my_acf_input_admin_footer() {
    	
    ?>
    <script type="text/javascript">
    (function($) {
    	
    // stop annoying keyboard popping up!  keep search input, but avoid autofocus on dropdown open
    $('select').on('select2:open', function (e) {
        $('.select2-search input').prop('focus',false);
    });
    		
    })(jQuery);	
    	
    </script>
    <?php		
    }
    
    add_action('acf/input/admin_footer', 'my_acf_input_admin_footer');

    -third detail, the checkboxes in taxonomy, some simple adjustments, but the most important thing missing is a search to find the terms to check, because there will be hundreds soon … note that the (+ ) add is adjusted globally to stay at the same level of the label

    here is the css code that I used :

    add_action('acf/input/admin_head', 'my_acf_admin_head');
    function my_acf_admin_head() {
    ?>
    <style type="text/css">
    
    	
    /* Fix Buttons reapeter */
    .acf-actions {
    text-align: left;
    }
    .acf-gallery {
    height: 450px!important;
    }	
    	
    /* Fix taxonomy select2 */	
    .select2-container.-acf .select2-selection {
    min-height: 30px;
    background: #fff url(data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E) no-repeat right 5px top 55%;
    background-size: 16px 16px;
    }
    .select2-selection__arrow {
    display: none;	
    }
    .select2-selection__placeholder {
    color: inherit!important;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__clear {
    cursor: pointer;
    float: left !important;
    padding-right:3px;
    }	
    	
    /* Mobile mode fields */	
    @media screen and (max-width: 782px){
    
    /* Adjust mobile fields */
    #full {
    min-width:100%;
     }
    	
    #half {
    min-width:50%;
     }
    	
    /* Fix gallery-toolbar buttons*/	
    .acf-hl>li {
    display: grid;
    min-width: 100%;
    z-index: 9!important; 
    }
    	
    /* Fix gallery-side*/	
    .acf-gallery .acf-gallery-side {
    position: fixed;
    z-index: 1000;
    }
    	
    /* Attempt to Fix gallery height*/	
    .acf-gallery .acf-gallery-attachments {
    height: 350px;
    }
    	
    /* Fix acf-actions */	
    .acf-actions {
    padding: 5px!important;
    margin: 0px!important;
    top:-35px!important;
    }
    	
    /* Fix taxonomy select2 */	
    .select2-container.-acf .select2-selection {
    min-height: 40px;
    padding: 4px 8px;
    font-size: 14px;
    background: #fff url(data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E) no-repeat right 5px top 55%;
        background-size: 16px 16px;
    }
    	
    /* Fix taxonomy select2 disable arrow */
    .select2-selection__arrow {
    display: none;	
    }
    	
    /* Fix taxonomy select2 color */
    .select2-selection__placeholder {
    color: inherit!important;
    }
    	
    /* Fix taxonomy select2 padding */	
    .select2-container .select2-selection--single .select2-selection__rendered {
    padding-left:0px !important;
    padding-right:0px!important;
    }
    	
    /* Fix numeric fields */	
    .acf-input-append,.acf-input-prepend {
    line-height: 2;
    min-height: 40px;	
    }
    	
    /* Fix radio list */
    ul.acf-radio-list li, ul.acf-checkbox-list li {
    line-height: 35px;
    }		
    	
    /* Fix Mobile make a clair visible scrollbar */
    .acf-taxonomy-field .select2-results .acf-gallery-main, ::-webkit-scrollbar{
    	width:20px;
    	background-color: #F7F3F3;
    }
    	
    .acf-taxonomy-field .select2-results .acf-gallery-main, ::-webkit-scrollbar-thumb{
    	border-radius: 20px;
    	background-color: #007CBA;
    	border: 7px solid #f7f3f3;
    	height: 90px;
    }
    	
    .acf-taxonomy-field .select2-results .acf-gallery-main, ::-webkit-scrollbar-track{
    	background-color: #f7f3f3;
    	border-radius: 0;
    }	
    	
    	
    	
    	
    	
    }	
    </style>
    
    <?php
    }

    that’s all I could do to make my interface less disruptive and mobile friendly and more welcoming to customers,

    I will wait for the reaction and ideas of the community, maybe someone has something even better??

    another detail … let’s try to stay positive and hope that the acf team surprises us with a mobile responsive fileds and friendly back-end update. I’m sure the chief designer at the acf team has something to tell us? I’m sure he doesn’t want to torture us creating css codes for simple fileds forever?

    don’t forget I’m just a simple user, I just know a bit of css …

  • Solving

    How to add row to ACF repeater field in Term

    I have a taxonomy with an ACF repeater field. I am trying to add rows in a callback for a custom REST API endpoint and having no luck. The scheme for the field is:
    `
    {
    “key”: “field_5faa2bc09fe7b”,
    “label”: “team”,
    “name”: “team”,
    “type”: “repeater”,
    “instructions”: “”,
    “required”: 0,
    “conditional_logic”: 0,
    “wrapper”: {
    “width”: “”,
    “class”: “”,
    “id”: “”
    },
    “collapsed”: “”,
    “min”: 0,
    “max”: 10,
    “layout”: “table”,
    “button_label”: “”,
    “sub_fields”: [
    {
    “key”: “field_5faa2bce9fe7c”,
    “label”: “Role”,
    “name”: “role”,
    “type”: “post_object”,
    “instructions”: “”,
    “required”: 0,
    “conditional_logic”: 0,
    “wrapper”: {
    “width”: “”,
    “class”: “”,
    “id”: “”
    },
    “post_type”: [
    “role”
    ],
    “taxonomy”: “”,
    “allow_null”: 0,
    “multiple”: 0,
    “return_format”: “id”,
    “ui”: 1
    },
    {
    “key”: “field_5faa2c0b9fe7d”,
    “label”: “User”,
    “name”: “user”,
    “type”: “user”,
    “instructions”: “”,
    “required”: 0,
    “conditional_logic”: 0,
    “wrapper”: {
    “width”: “”,
    “class”: “”,
    “id”: “”
    },
    “role”: “”,
    “allow_null”: 0,
    “multiple”: 0,
    “return_format”: “id”
    }
    ]
    }
    `
    I use the following to add a row to the field – and having no luck:

    `
    function wp_api_assign_internal_writer() {
    register_rest_route( ‘mynamespace/v1’, ‘assign_internal_writer/’, array(
    ‘methods’ => ‘POST’,
    ‘callback’ => ‘assign_internal_writer_callback’,
    ));
    }

    function assign_internal_writer_callback( $request ) {
    $parameters = $request->get_params();
    $task = $parameters[‘task’];
    $user = $parameters[‘user’];
    $project_set = $parameters[‘project_set’];
    if($task != ” && $user != ” && $project_set != ” ){

    $row = array(
    ‘field_5faa2bce9fe7c’ => ‘268’,
    ‘field_5faa2c0b9fe7d’ => $user
    );

    add_row(‘team’, $row, $project_set);
    return get_term_meta($project_set);

    }else{
    return ‘Please supply the correct request parameters, Task ID and User ID’;
    }
    }
    `
    Any idea what I am doing wrong? Does add row work only for Post and not Term….?

  • Helping

    CPT with default taxonomy and ACF

    Good day, i have a custom post type which I would want to show on a default category taxonomy page, so I add it to the query like so

    function add_custom_post_type_to_query( $query ) {
    	if ( is_admin() || !$query->is_main_query() )
            return $query;
    
    	if ( is_category() || is_tag() )  {
                $query->set( 'post_type', array('custom_post_type') );
    	}
    	
    	return $query;
    }
    add_action( 'pre_get_posts', 'add_custom_post_type_to_query' );

    and after that all of my “the_field()” on said category page doesn’t show up their values. How can i add a CPT to a query and make ACF keep working?

  • Solving

    update_field / update_sub_field not working in custom rest-api endpoint

    I am trying to update a sub field in a custom rest api endpoint.

    Structure of my acf is as follows:

    
            "fields": [
                {
                    "key": "field_5faa2483959b9",
                    "label": "field group",
                    "name": "field_group",
                    "type": "group",
                    "instructions": "",
                    "required": 0,
                    "conditional_logic": [
                        [
                            {
                                "field": "field_5faa23d8959b8",
                                "operator": "==",
                                "value": "content"
                            }
                        ]
                    ],
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "layout": "block",
                    "sub_fields": [
                        {
                            "key": "field_5fadbecbfcc8a",
                            "label": "field_1",
                            "name": "field_1",
                            "type": "post_object",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "post_type": [
                                "writer"
                            ],
                            "taxonomy": "",
                            "allow_null": 0,
                            "multiple": 0,
                            "return_format": "id",
                            "ui": 1
                        },
                        {
                            "key": "field_5fa0795d696df",
                            "label": "field_2",
                            "name": "field_2",
                            "type": "text",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "default_value": "",
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "maxlength": ""
                        }
                    ]
        

    This is the callback I am running on the endpoint:

    function assign_subfield_val( $request ) {
    
    $parameters = $request->get_params();
    $project = $parameters['project']; //number
    $writer = $parameters['writer']; //number
      if($writer != '' && $project != ''){
    
    	update_sub_field(array('field_5faa2483959b9', 1, 'field_5fadbecbfcc8a'), $writer, 2527);
    	
    	return gettype($project);
      }else{
    	  return $parameters;
      }
    
    }

    I have use update_field and update_sub_field, used both names and IDs, nothing is working.

    If I try to update a top-level field this way it works, but having issues with the sub field. Please help!

  • Solved

    ACF Text field in Woo Cat Page

    Hi folks,

    I am using the WooCommerce ‘taxonomy-product_cat.php’ file and I have added a text field.

    <h2><?php the_field(‘newtext’); ?></h2>

    But it looks like this on the Frontend:

    <h2></h2>

    In the backend, I have filled out the ACF field with some text, but it doesn’t show!

    What am I doing wrong?!

    Cheers for any help!

  • Solved

    How can I programmatically set a taxonomy field in wp_insert_post?

    Hello!

    I’ve been trying to update the taxonomy field while programatically inserting a post using wp_insert_post() but can’t figure out how to do it. Here is a sample code that is not working – the category_association meta field is empty:

    $cat_id = 100; // Term association that is actually output as a term_id
    
    $post_arr = array(
      'post_title'    => "My title",
      'post_status'   => 'publish',
      'post_type'     => 'page',
      'post_parent'   => $parent_id,
      'post_name'     => "my-slug",
      'meta_input' => array(
        'classified_association' => array($cat_id),
      )
    );
    
    wp_insert_post( $post_arr );
  • Helping

    Display posts by category

    Hello. Enthusiastic newbie here. I am trying to display posts by category.
    I have set up the taxonomy as below and assigned categories to products.

    function taxonomy ()
    {

    $args = array (

    ‘labels’ => array(

    ‘name’ => ‘Category’,
    ‘singular_name’ => ‘Category’,
    ),
    ‘public’ => true,
    ‘hierarchical’ => true, //set to false to make it appear or function more like tags. True means categories.

    );

    register_taxonomy(‘name’, array(‘products’), $args);

    };
    add_action(‘init’, ‘taxonomy’);

    The page output is:

    <?php if(have_posts()):while(have_posts()): the_post();?>

    I want to add in here something like:

    <?php if( in_category(‘cat1’) || cat_is_ancestor_of(‘cat1’, $current_category) ) {

    — then display these posts —

    ;?>

    Any help would be greatly appreciated.

  • Solving

    Taxonomy image = id, not url (or object)

    I have created a taxonomy field of type image (field group is displayed on a taxonomy, posttags. The return type of the image field is URL, but when I check the database, it has saved the ID. Data is also saved under termmeta.

    How can I save the image URL insted of the ID?
    I cannot retrieve any images from this field (I use Elementor – not code)

  • Unread

    can\'t get taxonomy titles into gutenberg block

    Hi,

    I’ve made a gutenberg block for a custom header. I can’t get the category value to populate. I’m getting ‘array’ instead of the category value. What am I doing wrong?

    $term = get_field(‘category_name’);
    $title = get_field(‘post_title’);
    $sub_title = get_field(‘sub_title’) ?: ‘Sub title here..’;
    $image = get_field(‘background_image’);
    $text_color = get_field(‘text_color’);

    ?>
    <div id=”<?php echo esc_attr($id); ?>” class=”<?php echo esc_attr($className); ?>”>

    <h6 class=”hero-category_name”><?php echo $term; ?></h6>
    <h1 class=”hero-post_title”><?php echo get_the_title($title); ?></h1>
    <p class=”hero-sub_title”><?php echo $sub_title; ?>

    <style type=”text/css”>
    #<?php echo $id; ?> {

    color: <?php echo $text_color; ?>;
    }
    </style>

Viewing 25 results - 501 through 525 (of 3,191 total)