Support

Account

Home Forums Search Search Results for 'field not displaying'

Search Results for 'field not displaying'

topic

  • Unread

    Repeater Image not Returning Image

    Hi,
    I’ve noticed when i want to call images in ACF Repeater, it returns its title and not the actual image.

    This is only for the ACF Repeater widget, on the others the images are displaying as they should.

    Iam returning image array from the custom fields in the repeater, ive tried with returning URL or image ID but doesnt work.

    Am i doing something wrong or is it a bug?
    Heres a video on what i mean:
    https://www.loom.com/share/fbafa3da099b4b4e88e6652aa01d5d67

    Regards,
    Mahir

  • Unread

    Image not displaying from array first time but it is the second time (same code)

    Hi

    I have the following groups and fields. The second group displays the background image absolutely fine but the first does not. WHY!!! Driving me crazy.

    
    <?php if( $highlightboxone ): ?>
      <div style="background: linear-gradient(0deg, rgba(102, 102, 102, 0.45), rgba(102, 102, 102, 0.45)), url(<?php echo esc_url( $highlightboxone['background_image']['url'] ); ?>) no-repeat center / cover;" class="box-highlight-item" data-aos="fade-up" data-aos-duration="600">
        <h2><?php echo $highlightboxone['headline']; ?></h2>
        <label><?php echo $highlightboxone['sub_headline']; ?></label>
        <a>"><button><?php echo $highlightboxone['button_text']; ?></button></a>	
      </div>
    <?php endif; ?>
    <?php if( $highlightboxtwo ): ?>
      <div style="background: linear-gradient(0deg, rgba(102, 102, 102, 0.45), rgba(102, 102, 102, 0.45)), url(<?php echo esc_url( $highlightboxtwo['background_image']['url'] ); ?>) no-repeat center / cover;" class="box-highlight-item" data-aos="fade-up" data-aos-duration="600">
        <h2><?php echo $highlightboxtwo['headline']; ?></h2>
        <label><?php echo $highlightboxtwo['sub_headline']; ?></label>
        <a>"><button><?php echo $highlightboxtwo['button_text']; ?></button></a>	
      </div>
    <?php endif; ?>
    
  • Solving

    ACF Frontend Functionality not working

    Hi everyone,

    I badly really need a help this error has been on the website for month and i can’t solve it.

    Suddenly the ACF PRO functionality on the frontend is not working like.
    1. Uploading
    2. Relationship field data not showing
    3. Conditional logic
    4. calendar date not displaying

    I’m using a latest version of ACF PRO using a Elementor builder.

    Upon checking the console. I get have this error

    Uncaught TypeError: Cannot read property ‘top’ of undefined
    at acf-input.min.js?ver=1600408311:3

    Hoping someone can help

    Thanks

  • Helping

    Persisting ACF Custom Field Type Value to a Database

    Using the ACF Starter Kit, I created a custom field type labeled “Plugin Host” (field name is ‘ph’), which is associated with a custom post type I created. I read through the ACF documentation but remain uncertain as how best to persist an instance of the custom field type’s value in the database set up for my WordPress web site. Here is some of the relevant code in question:

    // Create a default 'value' key/value pair within the constructor function
    $this->defaults = array(
      'value' => array(
                   'host' => 'uvi',
                   'version' => '1.0'
                 );
    );
    //Set up the GUI for displaying the custom field in a post's editor
    function render_field( $field ) {
      $field_value_keys = array_keys($field['value']);
    
      $host_key = $field_value_keys[0];
      $host_value = $field['value']['host'];
      $version_key = $field_value_keys[1];
      $version_value = $field['value']['version'];
    
      ?>
      <label
        for="plugin-<?php echo esc_attr($host_key); ?>">
        Plugin Host
      </label>
      <input
        type="text"
        id="plugin-<?php echo esc_attr($host_key); ?>"
        name="plugin-<?php echo esc_attr($host_key); ?>"
        value="<?php echo esc_attr($host_value) ?>"
      />
    
      <label
        for="plugin-version-<?php echo esc_attr($version_key); ?>">
        Plugin Host Version
      </label>
      <input
        type="text"
        id="plugin-<?php echo esc_attr($version_key); ?>"
        name="plugin-host-<?php echo esc_attr($version_key); ?>"
        value="<?php echo esc_attr($version_value) ?>"
      />
      <?php
    }

    The custom field type’s class, which extends the ‘acf_field’ class, includes both ‘update_field’ and ‘update_value’ methods, and each method includes the following comments, respectively:

    “This filter is applied to the $field before it is saved to the database”
    “This filter is applied to the $value before it is saved in the db”

    Since they are described as filters, I assume it means these functions are designed for use with the ACF WordPress filters ‘acf/update_field’ (see: https://www.advancedcustomfields.com/resources/acf-update_field/) and ‘acf/update_value’ (see: https://www.advancedcustomfields.com/resources/acf-update_value/).

    For the purpose of this post, I am interested only in updating the custom field type’s value in the underlying database’s postmeta table. If I am to use the ‘acf/field_value’ filter, then I assume that in this case it makes the most sense to use the ‘add_filter’ filter as follows:

    add_filter('acf/update_value/type=ph', 'my_acf_update_value_cb_func', 10, 4);

    Unfortunately, I am at a loss on how to implement this functionality. Here is what I have in mind, and I would appreciate your feedback for this approach.

    First, I assume the add_filter’s ‘acf/update_value’ hook is triggered after clicking the ‘update’ button in a post’s editor. Is this correct? Second, I assume the hook’s function will pass the $value modified value captured in the HTML tag for the custom field’s value in the post editor, the $post_id from the current post where the custom field value is contained, the $field value from the custom field’s identifier (either the ‘id’, the ‘key’ or the ‘name’), and the $original value as the custom field’s value prior to its modification. If so, then I thought about defining the callback function like this:

    function my_acf_update_value_cb_func($value, $post_id, $field, $original) {
      if(!empty($value)) {
        $result = '';
    
        // $ph_field is defined elsewhere using ACF's 'get_field' function
        $result = $ph_field->update_value($value, $post_id, $field);
    
        return $result;
      }
    }

    The ‘ph’ custom field class’ ‘update_value’ method would be defined as follows:

    function update_value($value, $post_id, $field) {
      $result = false;
    
      if(update_post_meta($post_id, 'value', $value)) {
        $result = true;
      }
    
      return $result;
    }

    In the interest of separation of concerns as a coding practice, the custom post editor’s ‘ph’ HTML render, the ‘acf/update_field’ WordPress filter and the ‘ph’ class’ ‘update_value’ method act, respectively, as the view, controller and model of an MVC design pattern.

    I have seen several posts here and elsewhere that advocate for persisting a custom field’s instance to a JSON file, but doing so only would require serializing to JSON within the ‘update_value’ method. For the purpose of this post, I am specifically interested in understanding how best to persist a custom field’s value to a database.

    I think the code I presented makes sense in principle, but I am not sure if the implementation is accurate. Also, I deliberately ignored validation, although this would be addressed by invoking the ‘ph’ class’ ‘validate_value’ method from within the ‘update_value’ method.

    Your I appreciate your recommendations. Thank you.

  • Solved

    Get ACF image array from taxonomy term

    Hi

    I am having some issues getting an ACF image field (array) from a taxonomy and displaying it in a loop on a page.

    I am looping through the Taxonomy terms with the following code. Its showing the term name and description no problem, but its not picking up the ACF field. Any ideas?

    <?php
    $terms = get_terms(
    array(
    ‘taxonomy’ => ‘tipo_reparacion_mob’,
    ‘hide_empty’ => false,
    )
    );

    $repair_icon = get_field(‘repair_type_icon’, $terms . ‘_’ . $term_id);

    if ( ! empty( $terms ) && is_array( $terms ) ) {
    foreach ( $terms as $term ) { ?>
    <div class=”swiper-slide”>
    <div class=”swiper-slide-inner”>
    <?php if( !empty( $repair_icon ) ): ?>
    <div class=”swiper-slide__icon”>
    ” alt=”<?php echo esc_attr($repair_icon[‘alt’]); ?>” />
    </div>

    <?php endif; ?>
    <h3 class=”heading–tertiary heading–mb-sm”>
    <?php echo $term->name; ?>
    </h3>
    <p>
    <?php echo $term->description; ?>
    </p>
    </div>
    </div>

    <?php
    }
    }
    ?>

    Thanks

  • Solving

    Issue with Oembed field

    I’m using the oEmbed field in a flexible content format. In my local environment, everything works just fine.

    <?php elseif (get_row_layout() == 'embed') :?>
              <div class="embed-full">
              <div class="embed-container">
              <?php the_sub_field('embed_link'); ?>
            </div>
            <p><?php the_sub_field('caption'); ?></p>
              </div>

    However, now that I’m trying to post an embed link on a live site, it’s not working. When I paste the link in, I don’t get a preview. And on the front end, it just returns a link that says False. The HTML shows this:
    <a href="http://false">false</a>

    When I go back into the CPT, instead of displaying the URL I had written, it now also says False and in the preview it says false. (see images atttached)

    Here’s an example (last item on the page): https://kellydmiller.com/portfolio/fanning-the-flame-2019/

    Also, yes, I deactivated all plugins except for ACF and CPTUI without which, the CPT wouldn’t work at all. However, no, I didn’t switch to a generic theme, because I don’t know how to test this on there without the code I have written in my custom theme.

  • Solving

    text field / any field not displaying on front-end ?

    Dear ACF,

    I created the field group and then created simple text field with the location rule to display on Front page and it does display on editor screen only.

    Added this function code in the custom front page template.

    <?php the_field(‘field_name’); ?>

    But it does not display!

    tried to display the field type with the following code so it shows a NULL in display!

    <?php var_dump( get_field(‘field_name’) ); ?>

    Kindly advice how to troubleshoot and fix it.

  • Unread

    Displaying images from a relationship field

    Hello.

    My objective is to create a link that includes imagery for another page (a ‘teaser’).

    Whereas I can obtain the post object data for the other page, I cannot obtain any of the imagery that exists on that page. This imagery exists in ACF blocks on that page.

    So… For example.
    On my Homepage I want to add a block containing a relationship field that I use to select Post1.

    On the homepage I want to show the first image displayed on Post1, along with it’s page title and a link to it.

    The images on Post1 are in ACF Blocks using an ACF image field.

    I cannot seem to get this information.

    In Block template:

    
    $featured_page = get_field('featured_page'); //returns ID
    $post = get_post(featured_page); 
    $post_content = esc_html($post->post_content) ;
    print_r($post_content);
    

    Returns:

    <!– wp:paragraph –> <p>Hello I am a wordpress paragraph.</p> <!– /wp:paragraph –> <!– wp:acf/text { “id”: “block_6006dfd2c7bd0”, “name”: “acf\/text”, “data”: { “block_size”: “1”, “_block_size”: “field_600598976d172”, “block_height”: “1”, “_block_height”: “field_6006dcd9995c5”, “text”: “i am text”, “_text”: “field_60059ea8de6d3” }, “align”: “”, “mode”: “preview” } /–> <!– wp:acf/html5-video { “id”: “block_6001be864c2b1”, “name”: “acf\/html5-video”, “data”: { “block_size”: “2”, “_block_size”: “field_600598976d172”, “block_height”: “2”, “_block_height”: “field_6006dcd9995c5”, “html5_video”: “https:\/\/vimeo.com\/472312157”, “_html5_video”: “field_6001bfb1e7116” }, “align”: “”, “mode”: “preview” } /–> <!– wp:acf/page { “id”: “block_600851c8dd8aa”, “name”: “acf\/page”, “data”: { “block_size”: “1”, “_block_size”: “field_600598976d172”, “featured_page”: [ “1” ], “_featured_page”: “field_60019ecd10af8” }, “align”: “”, “mode”: “preview” } /–> <!– wp:acf/text { “id”: “block_6005a7735a261”, “name”: “acf\/text”, “data”: { “block_size”: “1”, “_block_size”: “field_600598976d172”, “text”: “Thats the way we like to do it always. And i am rext\r\n\r\n “, “_text”: “field_60059ea8de6d3” }, “align”: “”, “mode”: “edit” } /–> <!– wp:acf/image { “id”: “block_6005bdd415fa0”, “name”: “acf\/image”, “data”: { “block_size”: “1”, “_block_size”: “field_600598976d172”, “image”: 89, “_image”: “field_60059e91e4284” }, “align”: “”, “mode”: “preview” } /–> <!– wp:acf/image { “id”: “block_60059ee53d2a2”, “name”: “acf\/image”, “data”: { “block_size”: “2”, “_block_size”: “field_600598976d172”, “block_height”: “1”, “_block_height”: “field_6006dcd9995c5”, “image”: 91, “_image”: “field_60059e91e4284” }, “align”: “”, “mode”: “preview” } /–> <!– wp:acf/image { “id”: “block_6005a5b57118c”, “name”: “acf\/image”, “data”: { “block_size”: “1”, “_block_size”: “field_600598976d172”, “image”: 90, “_image”: “field_60059e91e4284” }, “align”: “”, “mode”: “preview” } /–> <!– wp:acf/image { “id”: “block_6005e16015fa1”, “name”: “acf\/image”, “data”: { “block_size”: “3”, “_block_size”: “field_600598976d172”, “block_height”: “1”, “_block_height”: “field_6006dcd9995c5”, “image”: 92, “_image”: “field_60059e91e4284” }, “align”: “”, “mode”: “preview” } /–> <!– wp:acf/image { “id”: “block_6006e67cc7bd1”, “name”: “acf\/image”, “data”: { “block_size”: “1”, “_block_size”: “field_600598976d172”, “block_height”: “1”, “_block_height”: “field_6006dcd9995c5”, “image”: 89, “_image”: “field_60059e91e4284” }, “align”: “”, “mode”: “preview” } /–>

    How do I obtain the imagery from say, the first block on that page that contains an image; or say from the first three?

    Thanks!
    Rob

  • Solving

    Custom blocks editor not working after update

    Our developer used Advanced Custom Fields Pro to create the custom blocks for our website. Since the plugin update on 14th Jan and now when I go to edit my site pages, the blocks are not displaying in the CMS and say that our site doesn’t include support for ‘acf custom block name’ you can leave the block intact or remove it completely. These blocks made up the pages on the entirety of our website. fortunately it is all still showing on the live site ok at the moment, but I have had to revert to 13th Jan back up losing a lot of SEO work and have had to leave the Advanced Field Pro plugin not updated for now. Please can you advise on whether there is something I can do to fix this.

  • Solving

    How to add a search feature to ACF checkbox hierarchy

    Hello, I have created a fairly extensive anatomy hierarchy in ACF PRO for a medical site. This is a taxonomy set to display as checkboxes. The user needs to check the anatomy that a particular post relates to. The problem is that the anatomy list is very long, and users cannot find the item(s) they need. Is there a way in ACF to add a search feature when a taxonomy is displayed as checkboxes?

    I am familiar with displaying the taxonomy as as select field, which is then searchable. However, once you start searching, the user cannot see the rest of the hierarchy, and they are required to select all of the parents of the child elements. So I need them to be able to see the entire hierarchy the whole time. Basically I need the same thing a browser search does, but only in the one field area (not in the whole browser).

    Example:
    MSK
    – Knee
    – – Miniscus
    – Hand
    – – Finger
    – – Thumb

    When a user selects “Finger”, they are also required to select “Hand” and “MSK”. So searching for Finger in a select box doesn’t work, b/c they often do not know the name of a parent element that must be selected also. (I’m using easy-to-read examples here. Many of the items are using medical terminology that isn’t easy to read or remember).

  • Unread

    Load a sub field value of a Repeater field outside the loop

    I have a custom template that displays a portfolio using grids. When clicked, each grid item reveals more details in a fullscreen. To achieve this I’m using a repeater field, code bellow. Nothing wrong with the code, it work perfectly fine. Now, I need to display/load the sub field drawing_button outside the loop, but on the same fullscreen. I’ve tried every solution out there, with no avail. Instead of displaying the value related to each grid item, it displays all the values for all grid items on all fullscreen reveals.
    Any help would be very much appreciated, thank you!

    
    <div class="fullview">			
    
                    <?php if( have_rows('fullview_drawing') ): ?>
                    
                        <?php while( have_rows('fullview_drawing') ): the_row(); ?>
    
    			        <div class="fullview__item" style="background-image: url(<?php the_sub_field( 'fullview_image' ); ?>);">
    			            <div class="fullview__item-image">     
    				            <?php if( get_sub_field('fullview_image') ): ?>
    					            <img class="fullview__item-image" src="<?php the_sub_field( 'fullview_image' ); ?>" />
    				            <?php endif; ?>
    			            </div>
    				        <div class="fullview__item-titlewrap" id="fullview__item-titlewrap">
    				            <div class="fullview__item-title-cotainer">
                                    <h3 class="fullview__item-title"><?php the_sub_field( 'fullview_title' ); ?></h3>
    					            <div class="fullview__item-description"><?php the_sub_field( 'drawing_description' ); ?></div>
    					            <span class="fullview__item-more"><?php the_sub_field( 'drawing_button' ); ?></span>
    					        </div>
    				        </div>
    			        </div>
    
                        <?php endwhile; ?>
    
                    <?php endif; ?>
                    
                    <h3 class="fullview__title"><?php the_field('gallery_title'); ?></h3>
    
                </div>
    

    Here is a screenshot:

  • Solved

    Reusing a form like a repeater

    Hello everyone!

    I’m trying to use a form multiple times on one page, to capture a specific input for different labels, similarly to what a repeater does.

    The reason for this is that I am displaying information on a certain product in a table, and need to retrieve some user input next to it, for each product. This is why I cannot use a repeater.

    My question is, how would I go about retrieving the input values from the fields? I know that me messing with the way that ACF works will most likely result in ACF not providing the values out of the box, but I only need the values at submission time, not persistent.

    I have tried to alter the name of the field in the load_field filter, but it doesn’t seem to change the name attribute in the emitted HTML source.

    Anny ideas on how to accomplish this? Getting the values with the $_POST object would suffice as well.

  • Solving

    Date & Editor (WYSIWYG) not displaying on frontend

    Hey i’m trying to implement two date-fields and a editor field outside the wp-admin inclosure.

    The fields rendered, but the functions from the editor and date fields are nowhere to been seen.

    There are no javascript errors on load, but when I click on the “Visual”-btn, i get this error “Uncaught TypeError: Cannot read property ‘onpageload’ of undefined”.

    Anyone know how I can fix this and get it working ?

    Im using WP 5.5.3 and the theme is Astra Pro 2.6.1

  • Solved

    get_field occassionally returning string with repeater field

    Hello & good day!

    Our WordPress website (with the ACF plugins & a custom theme using these) is suffering some problems with the get_field() function – both with ACF repeater fields & just using get_field() in other parts of the custom theme.

    We have 3 of these repeater fields displayed on every page of our website (you can see for yourselves at uniqueteambuilding.com.au with the titles “As Seen On”, “Our Happy Clients”, “Testimonials” at the footer). And get_field() is also used for thumbnails throughout the site.

    From my investigations either all 3 of the repeater fields work and the thumbnails don’t, or all 3 of the repeater fields display empty content and the thumbnails display fine. This changes as you switch page in the site or refresh the page.

    When the galleries display empty content it is because the get_field() function returns a string, i.e. ‘string(1) “6”‘, instead of the expected array.

    The thumbnails not displaying may be another completely different issue, I still have more to go with that investigation. But it must be related & relevent in the sense that when these works, the repeater fields don’t. It appears (according to What The File plugin) that the relevant PHP template part file is only used when the thumbnails do work, i.e. when that appropriate file is being used and the get_field() function is called, then the get_field() function for the repeater fields returns that erroneous string.

    Below is the code being used for the repeater fields;

    <h3 class=”text-center”><?php the_field(‘as_seen_on_block_title’, “options”) ?></h3>
    <?php if ($logos = get_field(“as_seen_on_logos”, “options”)): ?>
    <ul class=”slider-as-seen-on”>
    <?php foreach ($logos as $logo) {…

    <h3 class=”text-center”><?php the_field(‘logo_block_title’, “options”) ?></h3>
    <?php if ($logos = get_field(“logos”, “options”)): ?>
    <ul class=”logos”>
    <?php foreach ($logos as $logo) {…

    <?php if ($testimonials = get_field(“testimonial_list”, “options”)): ?>
    <ul id=”testimonials” class=”bxslider”>
    <?php foreach ($testimonials as $testimonial) {…

    & here is the code used for the thumbnails;

    <?php $image = wp_get_attachment_image_src(get_field(‘event_thumbnail’), ‘full’); ?>
    ” alt=”<?php echo get_the_title(get_field(‘event_thumbnail’)) ?>” />

    Any advice or help fixing this would be amazing!!

    Thanks very much!
    Aidan

  • Solving

    Textarea not pulling line break from database

    Hello,

    I have data with new lines stored in a custom field (_position_title):

    Title1\nTitle2\nTitle3\nTitle4\nTitle5\nTitle6

    It displays fine on the front-end using explode:

    $position_titles =  explode( "\\n", get_field('position_title') );
    foreach ( $position_titles as $pt ):

    However, on the admin Edit Page, it does not convert the line breaks to new lines inside the textarea field that is for editing:

    Title1\nTitle2\nTitle3\nTitle4\nTitle5\nTitle6

    I tried every valid value for new_lines but this seems to only apply to get_field() – not displaying the data in the admin textarea.

     array(
    		'key' => 'field__position_title',
    		'label' => 'Position Title',
    		'name' => '_position_title',
    		'type' => 'textarea',
    		'instructions' => '',
    		'required' => 0,
    		'conditional_logic' => 0,
    		'wrapper' => array(
    		    'width' => '',
    		    'class' => '',
    		    'id' => '',
    		),
    		'default_value' => '',
    		'placeholder' => '',
    		'maxlength' => '',
    		'rows' => '',
    		'new_lines' => '',
    		'readonly' => 0,
    		'disabled' => 0,
    	    ),

    Any idea why the WP admin custom field is not converting \n to new lines inside the textarea? I’m using ACF Pro 5.7.9 and WP 5.4.4.

  • Solving

    ACF Galleries displaying empty

    Hello & good day!

    On our WordPress website (with the ACF plugin & custom theme using this), we have had some issues with Advance Custom Fields galleries in that they occasionally appear, but appear with no content. This is not what we want, obviously.

    We have 3 galleries displayed on every page of our website (you can see for yourselves at uniqueteambuilding.com.au with the titles “As Seen On”, “Our Happy Clients”, “Testimonials”) at the footer.

    Sometimes these galleries work fine, and other times they don’t – it changes each time you refresh and/or change page. I have noticed that all 3 of these galleries are either all not working at once or are all working at once.
    And when they are working, the image thumbnails of that page do not load & when they’re not working the image thumbnails are working.

    When (and only when) these galleries are not appearing, the debug.log gives PHP Warnings of; “Invalid argument supplied for foreach()” about each of these galleries (one warning for each gallery). These errors point to following code (for each of the galleries):

    <h3 class=”text-center”><?php the_field(‘as_seen_on_block_title’, “options”) ?></h3>
    <?php if ($logos = get_field(“as_seen_on_logos”, “options”)): ?>
    <ul class=”slider-as-seen-on”>
    <?php foreach ($logos as $logo) {…

    <h3 class=”text-center”><?php the_field(‘logo_block_title’, “options”) ?></h3>
    <?php if ($logos = get_field(“logos”, “options”)): ?>
    <ul class=”logos”>
    <?php foreach ($logos as $logo) {…

    <?php if ($testimonials = get_field(“testimonial_list”, “options”)): ?>
    <ul id=”testimonials” class=”bxslider”>
    <?php foreach ($testimonials as $testimonial) {…

    When the galleries load fine, no such warnings are given. So I’m assuming that this is the issue here.

    I believe this means that the fields aren’t set as (or being passed as) arrays, which would be preferred. I checked the ACF output log and saw that it was passed as arrays (although that may have only been when it was working). Perhaps when the galleries are not working, null is being passed to it & so that error is also thrown.

    It could also be a caching issue, which would make sense with the thumbnails not working… We would also love any advice on the thumbnails too if you know anything? It also used ACF functions but does not return any PHP warnings or errors. Here is the code for loading the thumbnails;

    <?php $image = wp_get_attachment_image_src(get_field(‘event_thumbnail’), ‘full’); ?>
    ” alt=”<?php echo get_the_title(get_field(‘event_thumbnail’)) ?>” />

    I’m not too sure where to go from here, I’ve spent a long time trying to figure this out & fix it but haven’t gotten very far. So any help & advice would be amazing!!

    Thanks very much!
    Aidan

  • Helping

    ACF & WooCommerce possible conflict when using page rule (shop)

    I have created a slider hero for the woocommerce.php template as well as repeater field with ACF that allows a user to insert additional slides to the slider with a rule that will only display the hero on the shop page.

    I have then created a template part that displays the hero so I don’t clogging up the woocommerce.php template with extra code.

    At that stage I had not yet added any products to my store and the hero is displaying and working as expected with the WooCommerce notice saying there is no products in the store, great, or so I thought.

    After completing the hero, I went ahead and added my first product to the store and guess what, the hero has completely disappeared. Now I’m left wondering how can I fix this? I have removed all of the CPT scripting and just echoed out a test message to see if the template is loading correctly and as expected it is, I see the test message echoed to the top of the store, where the hero should be.

    I’ve been at trying to get this working for an hour now and I can’t seem to come across anything that stands out to me. I have included the hero template part as well as the woocommerce.php template.

    woocommerce.php

    <?php
    /**
     * The template for displaying WooCommerce
     * 
     * @package StuCowley
     * @subpackage bellezashop
     * @since 1.0.0
     */
    
    get_header();
    
    get_template_part( 'template-parts/hero/shop-hero' );
    ?>
    
    <div class="sc-page-content">
      <?php woocommerce_content(); ?>
    </div><!-- /.sc-page-content -->
    
    <?php
    get_footer();

    shop-hero.php

    <?php
    /**
     * Template part for displaying the frontpage hero.
     * 
     * @package StuCowley
     * @subpackage bellezashop
     * @since 1.0.0
     */
    
    if ( have_rows( 'hero_slide' ) ) :
      while ( have_rows( 'hero_slide' ) ) : the_row();
        
        $headlineHeading = get_sub_field( 'headline_heading' );
        $headlineParagraph = get_sub_field( 'headline_paragraph' );
        
        $primaryBtnTitle = get_sub_field( 'primary_button_title' );
        $primaryBtnLink = get_sub_field( 'primary_button_link' );
    
        $secondaryBtnTitle = get_sub_field( 'secondary_button_title' );
        $secondaryBtnLink = get_sub_field( 'secondary_button_link' );
        
        $bgImg = get_sub_field( 'background_image' );
        $bgImgOverlay = get_sub_field( 'background_overlay' );
        $bgColour = get_sub_field( 'background_colour' );
        $bgTextColour = get_sub_field( 'background_text_colour' );
    
        // If the hero has a background image, echo the image
        if ( $bgImg ) {
    ?>
    
    <div id="shop-hero-slider">
      <section class="sc-hero-feature" style="background-image: url('<?php echo $bgImg; ?>'); background-color: <?php echo $bgImgOverlay; ?>; color: <?php echo $bgTextColour; ?> !important;">
    
      <?php 
      // Else if there is no background image applied, use the set background colour
      } elseif( $bgColour ) { 
      ?>
    
      <section class="sc-hero-feature" style="background-color: <?php echo $bgColour; ?>">
    
      <?php } ?>
        <div class="carousel-cell">
          <div class="sc-hero-feature-container">
            <h2 style="color: <?php echo $bgTextColour; ?>">
              <?php echo $headlineHeading; ?>
            </h2>
    
            <p style="color: <?php echo $bgTextColour; ?>">
              <?php echo $headlineParagraph; ?>
            </p>
    
            <?php if ( $primaryBtnTitle ) { ?>
            <div class="sc-hero-feature-btn-group">
              <div>
                <a href="<?php echo $primaryBtnLink; ?>" class="sc-hero-feature-btn sc-hero-feature-btn-primary">
                  <?php echo $primaryBtnTitle; ?>
                </a>
              </div>
            <?php } ?>
    
            <?php if ( $secondaryBtnTitle )  { ?>
              <span></span>
    
              <div>
                <a href="<?php echo $secondaryBtnLink ?>" class="sc-hero-feature-btn sc-hero-feature-btn-secondary">
                  <?php echo $secondaryBtnTitle ?>
                </a>
              </div>
            </div><!-- /.sc-hero-feature-btn-group -->
            <?php } ?>
          </div><!-- /.sc-hero-feature-container -->
        </div><!-- /.carousel-cell -->
      </section><!-- /.sc-hero-feature -->
    
      <?php
      endwhile;
      endif;
      
      wp_reset_postdata();
      ?>
    </div><!-- /#shop-hero-slider -->

    I’ve been backwards and forwards, re-typing checking for typos and I have come up empty. Is this feature even possible or is WooCommerce and ACF not going to play nice on this?

  • Unread

    Looping through repeater subfields and displaying a specific value

    First of all, I know, I’m very average in PHP, I’ve echo’ed the whole HTML, it’s awful, but that’s not the case. So I’m trying to create an ACF block repeater. My goal is that I output a grid of images (cards), and when I click on any of them, a video displays on screen and below the video, a person’s first and last name.

    So what I’ve done so far is that I’ve successfully generated the grid, but I’m stuck on the video and text part. Every grid item is meant to have an individual video sub-field, right now it’s hard-coded with an embed link.

    This is how it’s meant to be:Link

    So my question is – can I break the loop and only display the text and video that matches with the image I clicked, for example – I click on the fifth image, and only those values that I added to the fifth image are displaying.

    Right now with the loop I have, it displays every single value.

    PHP code:

    <?php 
    $rows = get_field('video');
    
    if( $rows ) {
        echo '<div class="grid">';
        foreach( $rows as $row ) {
            $image = $row['thumbnail'];
            $name = $row['name'];
            $surname = $row['surname'];
            $numberoforder = $row['number'];
            $class = $row['additionalclass'];
            echo '<div class="img ',$class,'" onclick="openVideo()">';
                echo '<div class="name oswald-regular"><p>',$name, '<br>' ,$surname, '</p></div>';
                echo '<img src=',$image,'>';
                echo '<div class="number-of-order oswald-md2"><p>',$numberoforder,'</p></div>';
            echo '</div>';
        }
        echo '</div>';
        echo '<div class="show-more-btn">';
        echo '<input value="Show more" id="btn" type="button" class="button" onclick="displayStories()">';
        echo '</div>';
        echo '<div class="personal-video" id="personal-video">';
        echo '<div class="video-container">';
        echo '<div class="closeBtn"><img src="/wordpress/wp-content/uploads/2020/11/close2.png" alt="Close" onclick="closeVideo()"/></div>';
        echo '<iframe width="560" height="415" src="https://www.youtube.com/embed/1PalAURGxtM?rel=0&modestbranding=1&controls=0" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen id="video1" onclick="playPause()"></iframe>'; //I'd want to display an individual video for each element also
        if (have_rows('inspiration-video')){
           while (have_rows('inspiration-video')) : the_row();
                $name1 = get_sub_field('name');
                $surname1 = get_sub_field('surname'); 
                echo '<h3 class="oswald-md2">'; 
                  echo $name1, " " ,$surname1;
                echo '</h3>';   
           endwhile;
        }
        echo '</div>';
        echo '</div>';

    Hope to get some advice.

  • 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

    Hide on empty on header

    Hey guys!

    I’m having trouble with the hide on empty feature,

    The problem is this: I’ve got a divi module in which there’s an header displaying the title of the module, and another module below it with the actual content.
    While the content module is not visible, the title does not disappear, even if I apply the hide on empty code to the header

    the code i am using to hide the title is this:

    <?php if( get_field('content_form') ): ?>
    	<h2>Content:</h2>
    <?php endif; ?>
  • Solving

    ACF Shortcode in Title, in Widget Title, in Search Results

    I am trying to create website to sell digital goods. Each product have it’s own version, and it can be updated. I use WooCommerce, and all versions are displayed in title and in attributes. But I can’t edit attribute field directly, and I also don’t like to write two times new version. So, I installed ACF and with the help of shortcode and php I can control now version numbers in title and in custom attribute field. Everything is working as intended, but I faced some big problems with displaying shortcode in different places.

    By default WordPress allow me to use shortcode only in post, to use it in title for example, I need to add something like thisin functions.php
    add_filter( 'the_title', 'do_shortcode' );

    But, it doesn’t work in other places on website at all. I can’t make it working in WooCommerce widgets, such as last products or featured products, I tried different combinations for “do_shortcode”.

    Also, default WordPress search and other plugins for search, and even plugin that displays tables of products are also don’t understand the shortcode, and showing only the shortcode itself, not the value.

    I also tried some plugins such as Shortcodes Anywhere or Everywhere, it didn’t help, ACF shortcode is not working in widget titles, in search result title etc etc.

    Product Page + Widgets
    Search Results

  • Solved

    Post Object: getting featured image alt tag

    I need to grab the alt tag for a featured image – I know how to get it normally but when I’m displaying the post via a Post Object I just get the error:

    Warning: Use of undefined constant ‘_wp_attachment_image_alt’ – assumed ‘‘_wp_attachment_image_alt’’ (this will throw an Error in a future version of PHP) in [url to template] on line 106

    Below is my code (commented out bits not working):

    $post_object = get_field('hp_project1');
    
        if( $post_object ): 
    
        $post = $post_object;
        setup_postdata( $post ); 
    
        $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
        //$thumb_id = get_post_thumbnail_id( $post->ID );
        //$thumb_alt = get_post_meta($thumb_id, ‘_wp_attachment_image_alt’, true);

    This will give me the image url fine:
    <?php echo $thumb[0]; ?>

    but
    <?php echo $thumb_alt; ?>

    will not give me the alt tag, which would normally work when not grabbing it via a acf post object.

    I google this for about an hour but couldn’t find anything specifically for grabbing it via Post Objects.

  • Solved

    Issue displaying taxonomies names and links: not a string?

    Hello, I am trying to display a simple list of custom taxonomies in my post via shortcode, but I get this warning:
    ltrim() expects parameter 1 to be string, object given

    In the backend i created an ACF form with Taxonomy field; main settings:
    name: custom_tax_fieldname
    appearance: checkboxes
    save terms: yes
    return value: term object

    In my php I added this code, borrowed and adapted from the documentation: https://www.advancedcustomfields.com/resources/taxonomy/

    $custom_taxonomies = get_field('custom_tax_fieldname');
    if( $custom_taxonomies ) {
    	foreach( $custom_taxonomies as $custom_taxonomy ){
            echo "<a href='" . esc_url( get_term_link( $custom_taxonomy ) ) . "'>" . esc_html( $custom_taxonomy->name ) . "</a>";
    		if (next( $custom_taxonomies )) {echo ', ';} 
     }
    }

    but I get this warning multiple times (one for every taxonomy I am supposed to see): Warning: ltrim() expects parameter 1 to be string, object given in home/wp-includes/formatting.php on line 4309

    I don’t know what am I doing wrong, can someone help?
    Thank you very much in advance

  • Unread

    ACF Form For Gallery Field

    I’m attempting to create a short code that will display a frontend ACF form for a gallery field with the same edit, upload, delete functions available on the backend. Its not displaying. What might I be missing?

    function acf_gallery_shortcode(){
     while ( have_posts() ) : the_post(); 
           $settings = array(
        	'id' => 'acf-form',
        	'fields' => array($fields['gallery']['key']),
        	'form' => true,
        	'submit_value'  => __('Update meta')
        );
            acf_form();
            endwhile; 
    }
    
    add_shortcode('acf-gallery', 'acf_gallery_shortcode');
  • Solving

    Display ACF fields that are modified by filters

    I am dynamically loading data into my field by using a filter on the field like this:

    add_filter('acf/load_field/name=custom_field','acf_custom_field_choices', 10, 1);

    When I try and display the field, it is displaying the original data from the field that I am now overwriting with the filter.

    Here is how I display the field:

    $field = get_field_object( 'custom_field' );
    $value = get_post_meta( $post_id, 'custom_field', true );
    echo $field['choices'][ $value ];

    Is there a better way to display a field value that’s data is being loaded via a filter, since it is not altering the original data of the field?

Viewing 25 results - 126 through 150 (of 508 total)