Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • 
    'meta_query'       => array(
    	array(
    		'key'      => 'event_end',
    		'value'    => $today,  // change this
    		'compare'  => '>'
    	)
    ),
    
  • Struggling with WooCommerce product filtering using taxonomies (“Model” and “Model Year”). The system fails to distinguish between models and assumes incorrect associations with model years.

    Solutions:
    Hierarchical Taxonomies:

    Make “Model” taxonomy hierarchical.
    Custom Taxonomy Structure:

    Combine “Model” and “Model Year” into a single custom taxonomy.
    ACF Relationship Field:

    Use ACF Relationship field for flexible relationships.
    Custom Meta Fields:

    Implement custom meta fields for precise data control.
    Custom Search Filters:

    Build custom search queries considering both taxonomies.
    Custom Code for Plugin:

    Customize the Search & Filter plugin for specific taxonomy handling.
    Developer Assistance:

    Seek help from a developer for complex customizations.

  • @fzs, thanks for your bug fix inspiration!

    Somehow in WP 6.4.2 it didn’t work for me.

    When I removed $taxonomy->meta_box_cb === false it worked, but for all categories on all post types.

    But since I only want to hide a specific custom category, I simply replaced it with $taxonomy->name === 'event-category'.

    So the final modified version is this:

    add_filter( 'rest_prepare_taxonomy', function( $response, $taxonomy, $request ) {
        $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
        // Context is edit in the editor
        if( $context === 'edit' && $taxonomy->name === 'event-category' ){
            $data_response = $response->get_data();
            $data_response['visibility']['show_ui'] = false;
            $response->set_data( $data_response );
        }
        return $response;
    }, 10, 3 );
  • This question is coming up more here since ACF added CPTs and Taxonomies.

    The answer is no, ACF cannot do this and there is no plugin that can do this. This must be coded and it is complicated.

    In these search results you will find several conversations on this topic [SEARCH RESULTS]

  • Thanks, John. I tried that but it didn’t seem to affect the Ajax validation, only the fields appearance. The JS solution is working well though so I’m going to run with that having now added in a check to see if the targeted for is being validated and ‘passing’ it if so:

    
    acf.add_filter('validation_complete', function( json ){
    
    	var	match 	= false,
    		val 	= "acf[field_123xyz]";
    
    	$.each( json.errors, function( index, value ){
    		if( value.input == val ) match = true;
    	} )
    
    	return match ? { valid: 1 } : json;
    });
    
  • I had a feeling that it would not work in the editor.

    Have you thought about trying to use the function get_current_screen().

    This function only exists on an admin page load and does not exist during AJAX requests. Testing to see if this function exists or not could tell you if it was the page load or not.

  • I solved this by first getting the field group and then individually addressing each one:

    // Extract the attributes
    		$atts = shortcode_atts( array( 'src' => '',  ), $atts, 'artwork');
    	
    		// Your PHP code here
    		$image_url = esc_attr($atts['src']); // sanitize the image URL from the shortcode attribute
    		$post_id = attachment_url_to_postid($image_url); // get the image post ID from the image URL using the WordPress function
    
    		$artwork = get_field('artwork', $post_id); // get artwork field group
    		$artfile = $artwork['artfile']; // get value of a flag that this is art file media
    		$title = trim($artwork['art-title']); // get title
    		$title = trim($title,'"'); // remove quotes
    		$year = trim($artwork['art-year']); // get year completed
    		$dimensions = trim($artwork['art-dimensions']); // get dimensions
    		$medium = trim($artwork['art-medium']); // get medium
    		$availability = $artwork['art-availability']; // get availability
  • Not always, it is counterintuitive to many that altering the value of a field in JS does not automatically trigger the change event.

    Initially, field groups are loaded based to the location rules of the page when it is loaded. Field groups are changed with an AJAX call. In the case of a new post you would have to set the parent page before the admin page is generated.

    See this stack exchanged topic https://wordpress.stackexchange.com/questions/59007/setting-a-default-parent-page

    You could use this to set the parent page based on your $_GET['parentid'] value and this should cause the parent ID set and the correct field groups to be loaded initially rather than altering the field and triggering the fields to be reloaded.

  • because acf does not passes the correct post id of each post in the query. instead it returns the post id of the query loop post. every post in that loop get the same id. therefore it won’t work as get_field always tries to return the values of the loop containing post.

  • Maybe I’m not understanding but why wouldn’t you just make an ACF block that pulls in what you need and they in the block editor nest that block inside the Query block or Post Temolate block?

  • The problem is that when ACF validates the fields this is done using AJAX and is_admin() is always true during AJAX requests, so the field is not required during the AJAX request but then it is required during the submission of the form.

    You also need to check wp_doing_ajax() and not remove the field requirement then as well.

  • Thanks, I realise the code is for select options. Can the code be modified to work with a text input. I am wanting to populate the quote_number field with the post_id after form submission. This will then be shown on the View Quote page after post creation as the unique quote number.

  • Has anyone ran into an issue when using wp-scripts package that the {block}.asset.php file gets auto-generated but has blank dependencies? For example, I have an editor.asset.php file in my src block files with the following code:

    <?php
    return array(
        'dependencies' => array(
            'wp-element',
            'wp-blocks',
            'acf-input', // way to make block js wait for window.acf to exists
        )
    );

    However, when wp-scripts generates my build directory, that file is generated/copied, however the contents is now:

    <?php return array('dependencies' => array(), 'version' => '9f262c201bd7fd5a3679');

    I was digging into the actual code within the node package that generates the contents of this file, and it appears the if statement within this code block never runs because this.externalizedDeps is always just an empty set.

    const chunkDeps = new Set();
    
    			if ( injectPolyfill ) {
    				chunkDeps.add( 'wp-polyfill' );
    			}
    			const processModule = ( { userRequest } ) => {
    				if ( this.externalizedDeps.has( userRequest ) ) {
    					chunkDeps.add( this.mapRequestToDependency( userRequest ) );
    				}
    			};

    Any thoughts..?

  • The post is updated to Processing through native woocommerce usage ( inside the Order, it is switched to status “processing” and then pressed the button “Update”.

    The field is a standard text field, available in the Order page to be edited, this is correct.

    By the way when running the code with some form of debugging like this

    add_action( 'woocommerce_order_status_processing', 'update_product_custom_field_', 10, 1 );
    function update_product_custom_field_( $order_id ) {
        // Log start of function
        error_log("Updating custom field for order ID: $order_id");
    
        // Generate the shipping number using the order ID
        $shipping_number = 'SHIPPINGNUMBERHERE';
    
        // Check if ACF function exists and update the custom field
        if (function_exists('update_field')) {
            $result = update_field( 'order_shipping_number', $shipping_number, $order_id );
            if ($result) {
                error_log("Successfully updated order_shipping_number for order ID: $order_id");
            } else {
                error_log("Failed to update order_shipping_number for order ID: $order_id");
            }
        } else {
            error_log("ACF update_field function not found.");
        }
    }

    it prints to the logs “Successfully updated order_shipping_number for order ID:”

    which makes it seem like the update_field is running correctly, but for some reason is not saving?

  • That looks like the one, yes, the toggles match the screen shot for that plugin https://wordpress.org/plugins/acf-quickedit-fields/

  • https://prnt.sc/nW_xTDTfcMqu

    Could you check this image? could be this plugin cause?

  • Bricks builder has a Query Loop interface. However, for queries based on Relationships or Repeaters there are no options for Order BY etc… I guess I will have to bypass Bricks and create the query myself. Thank you for taking the time to respond to me.

  • We are waiting for an answer to this question together. He interests me too!

  • I’m also interested in a similar question. 6 days have already passed, why has no one responded?

  • This would require saving the “print-size” post.

  • When I referred to “ACF settings,” I meant the Export option available under Tools in the ACF section of the admin panel. I was specifically talking about exporting the Field Groups.

    I’m considering setting up a small test site to share for verification purposes, but I’m not sure what the best approach is for that. For now, I plan to contact the developers.

    I would like to keep this thread open as I am also waiting for responses from others.

    Thank you for taking the time to look at my question.

  • Ah yes the block is wrapped inside a

    
    <?php 
      $case_study_category = get_field('case_study_category');
    			
      if( ($case_study_category) ) :
    ?>
    ...
    <?php endif; ?>
    

    The field is Taxonomy (Category)
    Return Value: Term ID

    Screen here of field page: https://postimg.cc/D4GNVRYQ

  • https://wordpress.stackexchange.com/questions/253640/adding-custom-columns-to-custom-post-types.

    However, I would also suggest that you copy the ACF venue name field to the post title because posts without titles can cause issues in WP, like not being able to move them to trash or delete them.

    https://www.google.com/search?q=acf+change+post+title+based+on+field+value+site%3Asupport.advancedcustomfields.com

  • @hube2
    Thank you for your prompt response.

    Regarding the code used for display, it is executed via the WordPress REST API. Below is a simplified version of the code. Please note that it may look odd due to simplification, but essentially, it’s just using get_field to retrieve data. Since the select field works correctly with choices that were initially present and after performing an export/import, I believe there is no bug in this code.

    
    <?php
    add_action('rest_api_init', function () {
        register_rest_route(
            'v1',
            'matches/(?P<slug>[a-z0-9_\-]+)',
            array('callback' => 'matchesResponse')
        );
    });
    
    function matchesResponse($request)
    {
        $post_args = [
            'name'              => $param_slug,
            'post_type'         => 'matches',
            'post_status'       => $request['post_status'],
            'posts_per_page'    => -1
        ];
    
        $post_query = new WP_Query($post_args);
    
        if ($post_query->have_posts()) :
    
            while ($post_query->have_posts()) :
    
                $post_query->the_post();
    
                global $post;
    
                $data[] = get_field('opponent', $post->ID);
    
            endwhile;
    
            wp_reset_postdata();
        endif;
    
        print_r($data);
    
        return new WP_REST_Response($data);
    }
    
    
  • How do you build a query to get the documents in “Brick”, that is a question for the builder you are using. All I can do is point you to the WP_Query doc.

Viewing 25 results - 2,976 through 3,000 (of 21,345 total)