Support

Account

Home Forums Search Search Results for 'remove comma'

Search Results for 'remove comma'

topic

  • Solving

    Check Box Output Commas

    Hi, I have read many answers about using “implode” to solve the issue about arrays and commas. Those where applied on a template file or code. But my case is that I am calling the value via [acf field="myfield"], which is inserted on a WordPress Post.

    I was able to create and display the value, however, the outcome shows a comma right after each value. How can I remove it, or is there any other way to do it other than CheckBox? Here is an example of my output:

    This is sentence one.,
    This is sentence two.,
    This is sentence three.

    How can I remove those commas?

    Thanks in advanced.
    Russ

  • Solved

    Change Repeater to ul and remove “,” separator

    I want to remove the comma separator and make each name/object in the repeater field separated per line. Is that possible to do?

  • Helping

    Block preview is wrapped in “extra” div (same classes), affects appearance

    I would love to hear some thoughts on this one.

    I have multiple blocks on which I have a custom field for adding width classes to the block (I don’t like Gutenbergs approach, I need my own). The selected class is appended to the blocks other regular css classes on the object.

    On my ACF blocks I use get_block_wrapper_attributes() to get the classes and then add them to a wrapper div. Apparently these classes is also added to the preview wrapping div in admin which means I get a double effect of my css rules.

    It removes the attribute classes on the inner div whenever clicking on the block but it’s back again whenever I reload the page.

    Anyone got a clue on why this happens and how I can solve it (my soultion mught be bad, I’m of course open for other totally different solutions)? This worked fine, as far as I know, before the summer (just got back to work and discovered this after updating WP 6.2.2 -> 6.3. and ACF 6.1.7 -> 6.2.0).

    Preferably I would not want these classes on the preview wrapping div, however they should in that case not be removed on the inner div when clicking on the preview.

    Double width classes creates double distance from the edges

    Same classes added to both parent and child div in preview mode of ACF Gutenberg block

    My block code:

    
    <?php
    $custom_wrapper_classes = 'my-block';
    include_once (get_stylesheet_directory() . '/includes/blocks/block-functions.php');
    
    if (function_exists('hest_get_wrapper_attr')) :
    	$wrapper_attributes = hest_get_wrapper_attr($block, $custom_wrapper_classes);
    endif;
    
    $posts = get_field('my_relationship_field');
    
    if( $posts ): ?>
    
    	<div <?php echo wp_kses_data($wrapper_attributes); ?>>	
    
    		<div class="my-grid">
    			<?php
    			global $post;
    			foreach( $posts as $post): 
    				setup_postdata($post);?>
    
    				 <!-- Code for outputting data -->
    			<?php
    			endforeach; ?>
    		</div><!-- .my-grid -->
    
    	</div><!-- .wrapper -->
    
    	<?php
    	wp_reset_postdata();
    
    endif; ?>
    

    hest_get_wrapper_attr() looks like this:

    
    <?php
    /*
     * Converts Gutenberg saved data attributes (input field by IPM plugin) to 
     * a string to echo on the wrapping div
     */
    function conv_data_attributes($data_attributes) {
    
        $data_attr = '';
        // Regular expression pattern to match the value inside the brackets
        $pattern = '/\[(.*?)\]/';
    
        // Perform the regular expression match
        if (preg_match_all($pattern, $data_attributes, $matches)) {
            // Extract the matched values
            $values = $matches[1];
            // Remove the commas from each extracted value
            $data_attr = array_map(function ($value) {
                return str_replace(',', '', $value);
            }, $values);
            // Convert the array into a space-separated string
            $data_attr = implode(' ', $data_attr);
        }
    
        return $data_attr;
    }
    
    /*
     * Converts Gutenberg saved gap value to CSS
     * 
     */
    function conv_blockgap_value($gap) {
        
        $pattern = "/var:([^|]+)\|([^|]+)\|([^|]+)/";
    
        $result = preg_replace_callback($pattern, function ($matches) {
            $lastValue = $matches[3];
            $updatedLastValue = preg_replace("/(\d+)([a-zA-Z]?)/", "$1-$2", $lastValue);
            return "var(--wp--{$matches[1]}--{$matches[2]}--{$updatedLastValue})";
        }, $gap);
    
        $gap = "gap: " . $result . ";";
        
        return $gap;
    }
    
    /*
     * Main function to prepare all wrapper classes, styles and attributes
     * 
     */
    function hest_get_wrapper_attr($block, $custom_wrapper_classes) {
        
        $wrapper_attributes = '';
        $alignment_classes = '';
        $style = '';
    
        // Support custom anchor values.
        $anchor = '';
        if ( ! empty( $block['anchor'] ) ) {
            $anchor = 'id="' . esc_attr( $block['anchor'] ) . '" ';
            $wrapper_attributes .= $anchor;
        }
    
        // Create class attribute allowing for custom "className" and "align" values.
        if ( ! empty( $block['align'] ) ) {
            $alignment_classes .= ' align' . $block['align'];
        }
    
        if ($block['supports']['alignContent'] == 'matrix') {
            // If matrix
            // Replace spaces: center left becomes center-left
            $alignment_classes .= ' has-custom-content-position is-position-' . str_replace(" ", "-", $block['alignContent']);
        } else {
            if ( ! empty( $block['alignContent'] ) ) {
                // If not matrix, get the alignContent
                // either top, center, or bottom
                $alignment_classes .= ' is-vertically-aligned-' . $block['alignContent'];
            }
        }
    
        // Block text alignment
        if( !empty($block['alignText']) ) {
            $alignment_classes .= ' has-text-align-' . $block['alignText'];
        }
    
        // Check if the block has fullHeight turned on
        if( !empty($block['fullHeight']) ) {
            $style .= 'min-height: 100vh;';
        }
        
        // Check if we got custom data attributes to add to our main div
        $data_attr = $block['dataAttributes'] ?? null;
        if ($data_attr && function_exists('conv_data_attributes') ) :
            $data_attr = conv_data_attributes($data_attr);
        endif;
    
        // Add blockGap value to wrapper attributes
        $gap = $block['style']['spacing']['blockGap'] ?? null;
        if ($gap && function_exists('conv_blockgap_value') ) :
            $gap = conv_blockgap_value($gap);
        endif;
    
        $style .= $gap;
    
        $wrapper_attributes .= get_block_wrapper_attributes(
            [
                'class' => $custom_wrapper_classes . $alignment_classes,
                'style' => $style,
            ]
        );
    
        $wrapper_attributes = $wrapper_attributes . ' ' . $data_attr;
    
        return $wrapper_attributes;
    }
    
  • Solving

    update_field returning large int instead of bool

    I’m using ACF Pro to create a Learning Management System. I’ve only recently started having problems. The main one that’s giving me the most trouble is that update_field() is not actually updating the field, despite me giving it accurate information and it working on a local environment (but not a WP Engine Dev environment).

    Currently I’m allowing the user to create a new Course (or “Module”), based on a previous one, specifically for their class. They choose which students they’ll be including, the Module to use a template, then the Chapters (or “Documents”) from that Module.

    Then, on the final screen, they review information, and the “Submit” button starts through a series of AJAX calls that sends the information to the server, sends back the pertinent info, then moves on to the next step.

    I’m sending back the results from each delete_field() and update_field command. When replacing values, I am deleting the current value (with delete_field()) before using update_field(). This has helped some of my issues, but not all.

    Here is the pertinent PHP code:

    
    <?php
    // I've made the CPT "Module" its own Class to contain its helper methods 
    $module = new ACF_Module( intval($module_id) );
    
    // I store the Documents (or "Chapters") for each Module (or "Course") as a 
    //     repeater field containing the document_id and the order it should 
    //     appear within the Module.
    $document_ids = json_decode( $_POST['document_ids']);
    $documents_field = [];
    $count = 1;
    
    foreach( $document_ids as $document_id ) {
        $documents_field[] = [
            'document_id' => intval($document_id),
            'order' => floatval($count),
        ];
        $count++;
    }
    
    // In JS, $documents_field_deleted = (bool) true
    $documents_field_deleted = delete_field($module->documents_field, $module->ID);
    
    // In JS, $documents_field_updated = (int) 625785,, or a similarly large number,
    //     which does not correlate to ANY existing post ID or user ID, as the 
    //     newest post_id in this example is 43113 and largest user ID is 1126
    $documents_field_updated = update_field($module->documents_field, $documents_field, $module->ID);
    

    I don’t know that this will matter, but just in case, here’s my JS doing the AJAX calls:

    
    // Triggered when clicking submit button labelled "Next"
    $('#submit').click(function(e){
        e.preventDefault();
    
        // I'm just storing values in hidden <code><input></code> fields. Since these 
        //     classes are all taken on a job-site, where the student is 
        //     monitored, I'm not concerned as much for the user being able to 
        //     change these.
        var nextAction = '';
        actionStep = $('input[name="acf_action_step"]').val();
    
        var payload = {
            action: 'acf_action_function_name',
            action_step: actionStep,
            agency_id: parseInt($('input[name="acf_agency_id"').val()),
            module_id: parseInt($('input[name="acf_module"]').val())
        };
    
        switch (actionStep) {
            case 'module':
                payload.module_title = $('input[name="acf_module_title"]').val();
                nextAction = 'chapters';
                break;
            case 'chapters':
                payload.chapter_ids = $('input[name="acf_chapters"]').val();
                nextAction = 'user';
                break;
            case 'user':
                var user_object = JSON.parse( $('input[name="acf_users"').val() );
                nextAction = 'user';
    
                if( user_object.length == 1 ) {
                    nextAction = 'finish';
                }
    
                payload.user_id = parseInt( user_object.shift() );
                user_ids = JSON.stringify(user_object);
                $('input[name="acf_users"]').val(user_ids);
                break;
            case 'finish':
                $('#submit').prop('disabled', true);
                $('#submit').addClass('disabled');
                return;
            default:
                break;
        }
    
        $.ajax({
            url: ajax_object.ajax_url,
            type: 'post',
            data: payload,
            beforeSend: function(){            
                $('#submit').prop('disabled', true);
                $('#submit').addClass('disabled');
            },
            success: function(response) {
                var response_object = JSON.parse(response);
                progress.append(response_object.message);
    
                if( response_object.new_module_id ) {
                    $('input[name="acf_module"]').val( parseInt(response_object.new_module_id) );
                }
            },
            complete: function(response) {
                $('input[name="acf_action_step"]').val( nextAction );
                $('#submit').prop('disabled', false);
                $('#submit').removeClass('disabled');
            }
        });
    
        return;
    });
    
  • Helping

    Removing extra space after comma

    I am using the Short Text field in ACF, but when I add a number like, for example, $4,000 it displays as $4, 000, with a space after the comma. How can I remove that?

  • Unread

    how to remove comma from stackable dynamics block

    hello i got problem , i was using stackable to create some dynamics blocks

    i using multiple checkbox as like photo

    when i output as content will showing with “,” i want to change to <breank> or just blank

    how i can do it ?

  • Solved

    How to Remove last comma from Gallery Loop?

    Hello, please tell me how can I remove the last comma in the photo output loop

    it’s my loop code:

    
    <img class="location__image" src="<?php echo get_the_post_thumbnail_url(get_the_ID() , 'medium_large'); ?>"
             data-hover-slides='<?php $location_gallery_urls = get_field('location_gallery'); ?><?php if ($location_gallery_urls): ?><?php foreach (array_slice($location_gallery_urls, 0, 5) as $location_gallery_url): ?><?php echo esc_url($location_gallery_url); ?>, <?php
        endforeach; ?><?php
    endif; ?>'>
  • Unread

    Replace Comma to Dash

    Hello.

    I need help changing the output numbers 44, 22, 33, 55 to 44-22-33-55 or just remove the comma.

    The result from the table column is generated using a shortcode plugin using the field name ‘winning-numbers-major’.

    I make sure to group all the number field so I can display using the shortcode.

    I appreciate any help. Thanks.

  • Solving

    Problem with commas

    Hi everyone,
    I know that the problem has often been asked on the forum but despite having tried everything I do not understand how to remove the commas on the front when using checkboxes.
    I am not a developer and I have trouble understanding how to do it.
    Could someone help me? 🙂

    Thanks in advance !

  • Helping

    Remove comma from last checkbox item

    Hi there,

    I’m sure this is quite trivial for your but I’m not a coder eh eh…

    I’ve manage to achieve what I want but I think it can be improved.

    I have a checkbox field, and I want to retrieve both label and value and want to separate them with a comma. This part is working fine. However, I want to remove the comma from the last item. I can add the comma in a span and then target the last span with CSS and remove it but I want it to be better.

    This is what I came up with by reading the docs and searching other topics

    <?php
    
    $plans = get_field('plans');
    if ( $plans) : ?>
    <div>
    <?php foreach( $plans as $plan ): ?>
           <a target="_blank" title="<?php echo $plan['label']; ?>" href="<?php echo $plan['value']; ?>"><?php echo $plan['label']; ?></a><span>,</span>
        <?php endforeach; ?>
    </div>
    <?php endif; ?>
  • Helping

    How to remove commas in ACF

    How To remove commas when using checkboxes
    I am trying to insert some custom tags for each product in my website. I use checkboxes in order to select tags and display on frontend. But the tags are displayed each item seperated with a comma (,). Can someone advice to how to remove this?

  • Unread

    How can I remove (,) from checkboxes?

    hello, I’m making a website for a real estate company, and I’m registering the leisure areas, such as soccer fields, gyms, pet places, these things … but when I look at the website, these elements are separated by commas and I want to remove these commas, is there any way other than by PHP? I don’t know anything about programming and I need to remove these commas. If the only solution is for PHP, send me the code already ready and the directory where I must insert this code.

    Advanced Custom Fields PRO
    Version 5.9.5

  • Helping

    custom category

    I have created a category with this code

    
    function custom_post_type() {
    
    // Set UI labels for Custom Post Type
    $labels = array(
    'name'                => _x( 'products', 'Post Type General Name', 'twentythirteen' ),
    'singular_name'       => _x( 'product', 'Post Type Singular Name', 'twentythirteen' ),
    'menu_name'           => __( 'Products', 'twentythirteen' ),
    'parent_item_colon'   => __( 'Parent Product', 'twentythirteen' ),
    'all_items'           => __( 'All products', 'twentythirteen' ),
    'view_item'           => __( 'View Product', 'twentythirteen' ),
    'add_new_item'        => __( 'Add New Product', 'twentythirteen' ),
    'add_new'             => __( 'Add New', 'twentythirteen' ),
    'edit_item'           => __( 'Edit Product', 'twentythirteen' ),
    'update_item'         => __( 'Update Product', 'twentythirteen' ),
    'search_items'        => __( 'Search Product', 'twentythirteen' ),
    'not_found'           => __( 'Not Found', 'twentythirteen' ),
    'not_found_in_trash'  => __( 'Not found in Trash', 'twentythirteen' ),
    );
    
    // Set other options for Custom Post Type
    
    $args = array(
    'label'               => __( 'products', 'twentythirteen' ),
    'description'         => __( 'product news and reviews', 'twentythirteen' ),
    'labels'              => $labels,
    // Features this CPT supports in Post Editor
    'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields','tags' ),
    // You can associate this CPT with a taxonomy or custom taxonomy.
    'taxonomies'          => array( 'genres' ),
    /* A hierarchical CPT is like Pages and can have
    * Parent and child items. A non-hierarchical CPT
    * is like Posts.
    */
    'hierarchical'        => true,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => 'page',
    );
    
    // Registering your Custom Post Type
    register_post_type( 'products', $args );
    register_taxonomy('categories', array('products'), array("hierarchical" => true, "label" => "Categories", "singular_label" => "Category", "rewrite" => array( 'slug' => 'products', 'with_front'=> false )));
    
    }
    
    /* Hook into the 'init' action so that the function
    * Containing our post type registration is not
    * unnecessarily executed.
    */
    
    //create two taxonomies, genres and tags for the post type "tag"
    function create_tag_taxonomies() 
    {
      // Add new taxonomy, NOT hierarchical (like tags)
      $labels = array(
        'name' => _x( 'Tags', 'taxonomy general name' ),
        'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Tags' ),
        'popular_items' => __( 'Popular Tags' ),
        'all_items' => __( 'All Tags' ),
        'parent_item' => null,
        'parent_item_colon' => null,
        'edit_item' => __( 'Edit Tag' ), 
        'update_item' => __( 'Update Tag' ),
        'add_new_item' => __( 'Add New Tag' ),
        'new_item_name' => __( 'New Tag Name' ),
        'separate_items_with_commas' => __( 'Separate tags with commas' ),
        'add_or_remove_items' => __( 'Add or remove tags' ),
        'choose_from_most_used' => __( 'Choose from the most used tags' ),
        'menu_name' => __( 'Tags' ),
      ); 
    
      register_taxonomy('tag','products',array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'update_count_callback' => '_update_post_term_count',
        'query_var' => true,
        'rewrite' => array( 'slug' => 'tag' ),
      ));
    }
    
    add_action( 'init', 'create_tag_taxonomies', 0 );

    How can I display the list of posts of that taxonomy using the ÙŽACF plugin’s taxonomy feature?

    https://www.advancedcustomfields.com/resources/taxonomy/

  • Unread

    Remove commas on elementor

    Multiple Select Field – remove commas on elementor?

  • Solved

    Remove commas (checkbox)

    Hi!

    I use this code with my checkbox, but would like to remove the commas.

    `
    <p class=”shop-link”><?php the_field(‘shop’); ?></p>
    `
    I’ve searched the forum and tried different codes without any luck.

    For example, this didn’t work so I appreciate all help!

    `
    <p class=”shop-link”><?php $values = get_field(‘checkbox’);
    if ($values) {
    foreach ($values as $value) {
    echo str_replace(‘, ‘, ‘<br />’, $value);
    }
    } the_field(‘shop’); ?></p>
    `

    Thank you,
    Caroline

  • Solved

    Output comma separated list of repeater sub field values

    I have an ACF repeater field field_5f71d4eaaf381 for email addresses and I want to output a comma separate list of the sub field values (measurement_extra_email_address) to create a $to for the WordPress mail function.

    
    			$values			  = $_POST['acf'];
    			$extra_recipients = $_POST['acf']['field_5f71d4eaaf381'];
    
    			if ( $extra_recipients ) {
    				$list = array();
    				foreach( $extra_recipients as $extra_recipient ) {
    					$list[] = $extra_recipient['measurement_extra_email_address'];
    				}
    				$to = implode(',', $list);
    			}
    

    I thought above code should/would do it but no email is being send so I guess the code is incorrect..?

    Just a note: When I remove above part of the code and just try $to = '[email protected]'; an email is being send so the error should be in there…

  • Solving

    Display a linkable URL and Remove the comma

    Hello

    I’ve been using ACF and a few things have got me stumped.

    1st
    I have a site setup in elementor and have tried using the URL and Link fields in ACF to allow users to put in a website domain in a field for a member profile.
    However when ever it displays via ACF shortcode, the url is not linkable, how do i make it link to the URL thats been put in the ACF field?

    2nd
    https://www.cider.ordesign.me/member/westons/
    How do i remove the commas between the icons, under whats on offer?

    Thanks

  • Solved

    My post stopped working

  • Solved

    Remove the comma (,) in the line break.

    I would like to be able to remove (,) every time a newline occurs in the labels field.
    Can you help me, please?

    Thank you

    <h6 class="audio-tags">
                            <?php
                                $tags = get_field("etiquetas");
                                $tagArray = explode(",", $tags);
    
                                foreach($tagArray as $tag){
                                    echo("<div class='tag-wrap'>".$tag."</div>");
                                }
                            ?>
                        </h6>
  • Solving

    Replace Comma With Line Break On Select Field Type When Using ACF Shortcode

    Hi there,
    Programming noob here. I use ACF on my website to display affiliate links to products on Amazon. I achieve this by using a “select” field type with the return format set to “both (array)”. The “value” is the Amazon SiteStripe image code and the “label” is a short product description. I implement this on my Elementor page builder using the acf shortcode [acf field="field_name"], since Elementor’s dynamic tags doesn’t seem to work properly with select field types.

    Overall I am happy with how it looks, but I would like to remove the comma “, ” that seaparates the value and the label on the frontend and replace it with a line break <br>.

    I searched around your forum before posting this and interestingly enough, I found a post extremely similar to mine, located here: https://support.advancedcustomfields.com/forums/topic/checkbox-field-commas-shortcode-for-get_field/

    I tried implementing the code snippet posted there into my functions.php, but when I visited my site I was met with a “There has been a critical error on your website” message.

    Like the other person in the above post, my knowledge of php is very limited, so I wondered if someone could be so kind as to provide me with a code that I can also add to my functions.php file that would allow me to achieve the desired line break in place of the comma?

    Many thanks.
    Tom

  • Solved

    String replace in a value

    I have some checkbox options which return values like this:
    address1, address2, postcode
    I’d like to remove the commas in the returned values and replace with a line break.
    This is where I’ve got to, alas it doesn’t work.
    <?php echo str_replace(', ', '<br />', get_field('myfield', 'option')); ?>

  • Solved

    How do I reserve categories for a Custom Post Type?

    I want to be able to add categories to a Custom Post Type, and have those categories reserved for the CPT and not be used by standard posts, and only appear under the Field Type Taxonomy.

    I’m using the functions below to generate the CPT Report and add a taxonony of categories. With it, I can add categories under the left-hand admin menu, and the standard WordPress metabox appears, too.

    But when I use the ACF field type Taxonomy to select categories while creating a Report, I see all categories, even those for blog posts.

    How do I limit the Field Type to the specific categories for the Report CPT?

    And, how do I get rid of the metabox for categories but retain the admin menu item under the CPT? I tried ‘show_ui’ => false but that kills the admin menu item.

    function report_post_type() {
    
        register_post_type('report',
            array(
                'labels' => array(
                    'name' => __('Reports'),
                    'singular_name' => __('Report'),
                    'add_new' => __('Add New'),
                    'add_new_item' => __('Add Report'),
                    'edit' => __('Edit'),
                    'edit_item' => __('Edit Report'),
                    'new_item' => __('New Report'),
                    'view' => __('View Report'),
                    'view_item' => __('View Report'),
                    'search_items' => __('Search Reports'),
                    'not_found' => __('No reports found'),
                    'not_found_in_trash' => __('No reports found in Trash')
                ),
                'public' => true,
                'hierarchical' => true,
                'has_archive' => false,
                'supports' => array(
                    'title',
                    'revisions'
                ),
                'can_export' => true,
                'menu_position' => 5,
                'menu_icon' => 'dashicons-clipboard',
                'rewrite' => array(
                    'slug' => 'report',
                    'with_front' => false,
                    'hierarchical' => true
                ),
            )
        );
    }
    
    function reports_taxonomy() {
    
        $labels = array(
            'name'                       => _x( 'Report', 'Taxonomy General Name', 'text_domain' ),
            'singular_name'              => _x( 'Report', 'Taxonomy Singular Name', 'text_domain' ),
            'menu_name'                  => __( 'Categories', 'text_domain' ),
            'all_items'                  => __( 'All Items', 'text_domain' ),
            'parent_item'                => __( 'Parent Item', 'text_domain' ),
            'parent_item_colon'          => __( 'Parent Item:', 'text_domain' ),
            'new_item_name'              => __( 'New Item Name', 'text_domain' ),
            'add_new_item'               => __( 'Add New Item', 'text_domain' ),
            'edit_item'                  => __( 'Edit Item', 'text_domain' ),
            'update_item'                => __( 'Update Item', 'text_domain' ),
            'view_item'                  => __( 'View Item', 'text_domain' ),
            'separate_items_with_commas' => __( 'Separate items with commas', 'text_domain' ),
            'add_or_remove_items'        => __( 'Add or remove items', 'text_domain' ),
            'choose_from_most_used'      => __( 'Choose from the most used', 'text_domain' ),
            'popular_items'              => __( 'Popular Items', 'text_domain' ),
            'search_items'               => __( 'Search Items', 'text_domain' ),
            'not_found'                  => __( 'Not Found', 'text_domain' ),
            'no_terms'                   => __( 'No items', 'text_domain' ),
            'items_list'                 => __( 'Items list', 'text_domain' ),
            'items_list_navigation'      => __( 'Items list navigation', 'text_domain' ),
        );
        $args = array(
            'labels'                     => $labels,
            'hierarchical'               => true,
            'public'                     => true,
            'show_ui'                    => true,
            'show_admin_column'          => true,
            'show_in_nav_menus'          => true,
            'show_tagcloud'              => true,
        );
        register_taxonomy( 'Report', array( 'report' ), $args );
    }
    
    add_action('init', 'report_post_type');
    
    add_action( 'init', 'reports_taxonomy', 2 );
  • Unread

    Remove Seperator in Repeater Output

    Hello! When displaying content of repeater via the shortcode [acf field="field_name"] I am getting a comma seperator between each value. Right now this is a output like “10, Minutes”. but it should be without the comma. can I remove it via the functions.php?

    hope you can help me

  • Solved

    Checkbox Field, Commas, Shortcode for get_field?

    I’m hoping someone can help me.

    I’m using ACF (versions 5.7.7) to add content to the bottom of every post. I have a checkbox field which consists of a list of resources which I consistently use in formulating blog posts and when I’m done writing a post, I can check the checkboxes for the resources I used and a “Resources Used For This Article” will appear at the bottom of the post. The field’s Return Value is set to Value. I am using the ACF shortcode within a different plugin’s content (the plugin is Simple Custom Content – https://wordpress.org/plugins/simple-custom-content/).

    That is working great, except that the output of the ACF shortcode is a comma-delimited list of values. I would prefer that the values be separated by line breaks instead of commas.

    I’ve searched through the forums and found several ideas that could prove helpful in my situation:

    https://support.advancedcustomfields.com/forums/topic/xav/
    https://support.advancedcustomfields.com/forums/topic/unwanted-commas-on-frontend/
    https://support.advancedcustomfields.com/forums/topic/multiple-select-field-remove-commas-from-output/
    https://support.advancedcustomfields.com/forums/topic/comma-separated-array-values/
    https://support.advancedcustomfields.com/forums/topic/cpt-archive-need-custom-field-values-as-classes-for-each-post/

    My problem is that I am not experiencing with editing plugins or even with PHP. About the extent of what I can do is take a snippet of code that is given to me and add it to an existing file, as long as someone tells me where exactly to add it (what file and where within the file). The threads I list above seem very promising to me, but all of them appear to be written for people who are much more experienced than I am.

    I think what would be ideal is if I could add code (to functions.php I assume) that would create a shortcode for get_field (which, if I understand the threads above correctly, is necessary to retrieve a list of the checkbox values without commas. That way, I could just use this new shortcode within the Simple Custom Content plugin and only have to do a minimal amount of editing of code.

    Am I on the right track, and if so, how would I create the shortcode for get_field?

    Thanks in advance for any help anyone can offer – it’s much appreciated!

  • Solved

    Separating last row from others

    Hi guys, I’ve created a repeater field that calls a color picker for each row. My aim is to use this to populate a css field for a gradient.

    The idea is for a bike shop where the colors will be used for a little visual element on each listing. Currently my code looks like the following:

    
    <div class="colorbar" id="colorbar-<?php the_ID(); ?>"></div>
    <style>
    #colorbar-<?php the_ID(); ?>{ 
        <?php if( have_rows('bike_color') ): ?>
        <?php while ( have_rows('bike_color') ) : the_row(); ?>
            background-image: linear-gradient(to right, <?php the_sub_field('color'); ?> );
        <?php  endwhile; ?>
         <?php endif ?>
    }
    </style>
    

    Because of how the sub_field for color is output with just a hexcode, the gradient fails because it requires a comma between each color.

    I had an idea of doing something along the following:
    All rows:

    $rows = get_field( ‘bike_color’);
    $end_row = end( $rows ); // get the end row
    $color_select = $end_row[‘color’]; // get the sub field value
    $each_row = $color_select . ‘, ‘; //adding a comma after the sub field output
    echo $each_row;

    Last row:

    $rows = get_field( ‘bike_color’);
    $end_row = end( $rows ); // get the end row
    $color_select = $end_row[‘color’]; // get the sub field value
    $last_row = $color_select; // No comma added for last row.
    echo $last_row;

    Basically I want to output all rows except for the last with a comma added and then output the last row without a comma because if it’s added to the last color selected, it fails in the css selector. I think it would work nicely for what I’m planning because if a single color was selected, it’d be the last row and so the comma would be removed.

    I think I’m fairly close but any help would be greatly appreciated. 🙂

Viewing 25 results - 1 through 25 (of 67 total)