Support

Account

Home Forums Search Search Results for 'field not displaying'

Search Results for 'field not displaying'

topic

  • Unread

    Show a different Font Awesome icon for each ACF checkbox choice – frontend

    Hi

    I’m hoping someone can help me as I’m banging my head against a brick wall here. I’m using ACF Pro and Elementor Pro. I have setup a CPT using the CPT UI plugin and have then created an ACF group with a checkbox field type. I am using Elementor Pro to dynamically pull the selected checkbox choices into my page template. I don’t want the choices to display as an inline list with comma separation, I want them to display as an unordered bullet list. I found some code to add to my functions.php so that I can add a shortcode to the page which displays the choices as mentioned, this works well.

    However, I don’t want to stop there. I would like each selected choice to show a different Font Awesome icon for each ACF checkbox choice that’s been selected. So as an example, I’m trying to list office amenities such as parking, cafe, bike store, wifi and I want these in an unordered list with the icon for each displaying on the left of the text. I’ve managed to set it up to use the same Font Awesome icon for each but am stumped as to how to get different icons for each. I am not confident in PHP so please bear with me.

    This is the code I have in my functions.php to make the shortcode…

    function custom_acf_shortcode( $atts ) {
    	// extract attributs
    	extract( shortcode_atts( array(
    		'field'			=> 'property_amenities',
    		'post_id'		=> false,
    		'format_value'	=> true
    	), $atts ) );
    
    	$value = get_field( $field, $post_id, $format_value );
    
    	if( is_array($value) )
    	{
    		$ul = '<ul class="fa-ul">';
    		foreach($value as $val) {
    			$ul .= '<li><span class="fa-li"><i class="fas fa-check-square"></i></span>' .$val. '</li>';
    		}
    		$ul .= '</ul>';
    		$value = $ul;
    	}
    
    	return $value;
    }
    add_shortcode( 'custom_acf', 'custom_acf_shortcode' );

    Any help would be much appreciated.

    Many thanks!!

  • Unread

    ACF checkbox frontend display list with a different icon for each choice

    Hi

    I’m hoping someone can help me as I’m banging my head against a brick wall here. I’m using ACF Pro and Elementor Pro. I have setup a CPT using the CPT UI plugin and have then created an ACF group with a checkbox field type. I am using Elementor Pro to dynamically pull the selected checkbox choices into my page template. I don’t want the choices to display as an inline list with comma separation, I want them to display as an unordered bullet list. I found some code to add to my functions.php so that I can add a shortcode to the page which displays the choices as mentioned, this works well.

    However, I don’t want to stop there. I would like each selected choice to show a different Font Awesome icon for each ACF checkbox choice that’s been selected. So as an example, I’m trying to list office amenities such as parking, cafe, bike store, wifi and I want these in an unordered list with the icon for each displaying on the left of the text. I’ve managed to set it up to use the same Font Awesome icon for each but am stumped as to how to get different icons for each. I am not confident in PHP so please bear with me.

    This is the code I have in my functions.php to make the shortcode…

    
    function custom_acf_shortcode( $atts ) {
    	// extract attributs
    	extract( shortcode_atts( array(
    		'field'			=> 'property_amenities',
    		'post_id'		=> false,
    		'format_value'	=> true
    	), $atts ) );
    
    	$value = get_field( $field, $post_id, $format_value );
    
    	if( is_array($value) )
    	{
    		$ul = '<ul class="fa-ul">';
    		foreach($value as $val) {
    			$ul .= '<li><span class="fa-li"><i class="fas fa-check-square"></i></span>' .$val. '</li>';
    		}
    		$ul .= '</ul>';
    		$value = $ul;
    	}
    
    	return $value;
    }
    add_shortcode( 'custom_acf', 'custom_acf_shortcode' );
    

    Any help would be much appreciated.

    Many thanks!!

  • Helping

    Editing custom fields like in a spreadsheet

    Hello,
    I’m looking for an option to edit posts with custom fields in a table/spreadsheet view: I have a custom post type with several custom fields. In addition to the standard edit page where title/author/date is shown for all posts, I would like to have a page where all the custom fields are shown like in a spreadsheet (similar to Excel/Calc etc.) and are even editable (at the end of each row an Update button).

    Does a plug-in like this on top of ACF exist or is there a simple way to generate edit fields from ACF so I get the HTML code for one field given the post ID and field name/id (for value checking, displaying/selecting post names for post objects)?

    To make this clear (because this is what I always ended up finding when I was searching for solutions): I do not want a custom field type for a table/spreadsheet, nor do I want a non-standard database layout in a separate SQL table nor a way to display a table for the users. All I want is more comfort in editing custom fields of multiple posts 🙂

    Best regards
    Stefan

  • Unread

    The ACF field does not work properly with Redis Cache

    Description:

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

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

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

    Issue:

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

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

  • Solving

    ACF fields doesn\'t appear on PHPmyadmin unless i update each custom post type

    I have created some new ACF fields and it’s working fine and displaying the value.
    but I have like 600 fields not updated these fields doesn’t appear on the backend unless i click update post.
    I tried to bulk update posts but it didn’t work.
    I tried to use this code to force update field but no success as well

    $value = (int)get_field('starter_annual_plan_free_trial_url');
    if (!$value) {
      $value ++;
    update_field('starter_annual_plan_free_trial_url', $value );
  • Solving

    Product hover image not displaying

    We are trying to figure out why the hover images on our Woocommerce shop page are not displaying anymore. We have no contact with the theme developers anymore but were able to find the following codes in the theme files:

    {
        "key": "group_5e2871966914d",
        "title": "Product",
        "fields": [
            {
                "key": "field_5e2875af54486",
                "label": "Hover Image",
                "name": "hover_image",
                "type": "image",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "return_format": "array",
                "preview_size": "medium",
                "library": "all",
                "min_width": "",
                "min_height": "",
                "min_size": "",
                "max_width": "",
                "max_height": "",
                "max_size": "",
                "mime_types": ""
            }
        ],
        "location": [
            [
                {
                    "param": "post_type",
                    "operator": "==",
                    "value": "product"
                }
            ]
        ],
        "menu_order": 0,
        "position": "normal",
        "style": "default",
        "label_placement": "top",
        "instruction_placement": "label",
        "hide_on_screen": "",
        "active": 1,
        "description": "",
        "modified": 1579710438
    }
    .post-type-archive-product main,
    .archive.tax-product_cat main {
        margin-top: 80px;
    }
    
    .products {
        list-style: none;
        padding: 0;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
    }
    
    .products .product {
        width: 33.33%;
        padding: 0 1px;
    }
    
    .product-img-wrapper {
        position: relative;
        display: flex;
    }
    
    .product-img-wrapper img {
        width: 100%;
        height: intrinsic;
    }
    
    .product-img-wrapper img:last-of-type {
        position: absolute;
        top: 0;
        left: 0;
        opacity: 0;
        visibility: hidden;
        z-index: 1;
        transition: all 0.25s ease-in-out;
    }
    
    .product-img-wrapper:hover img:last-of-type {
        opacity: 1;
        visibility: visible;
    }

    Any help would be much appreciated. This feature stopped working a few weeks ago when we updated to the newest version of WordPress.

  • Solved

    Order by custom field not working

    I have a list of custom post types that I’m displaying, with the intention of displaying them in order of campaign_end_date which is a custom field.

    I’m running a WP_Query with the following attributes:

    
    $crowdfunding_posts = new WP_Query(get_posts(array(
        'post_type'   => 'crowdfunding',
        'numberposts' => 30,
        'meta_key' => 'campaign_end_date',
        'order_by' => 'meta_value',
        'order' => 'ASC',
    )));
    

    I retrieve the raw data with this query

    
    select
    	p.post_title, 
    	pm.meta_value
    from wp_posts p
    inner join wp_postmeta pm on pm.post_id = p.ID
    where pm.meta_key = 'campaign_end_date'
    and p.post_status = 'publish'
    order by pm.meta_value asc
    

    and based on that, the expected order of these posts should be:

    
    POST_ID	POST_TITLE	META_VALUE
    257396	Comic Book Bubble	20220913
    257398	Trailblazers	20220916
    257403	CobbleCritters	20220922
    257404	Kinfire Chronicles: Nights Fall	20220921
    257405	Sea of Legends: Vengeance of the Empires	20220915
    257406	Almost Innocent	20220920
    257862	Weavlings in the Wilds	20220929
    257863	River Trek	20220909
    257864	Bakufu: A Japanese Themed Strategic Card Game	20220920
    257865	Full Sun	20220917
    257866	Diamond Dig	20220920
    257867	Barbaric	20220906
    257868	Dwar7s Legendary Forest	20220921
    

    But on page they’re displaying in the following order.

    
    Comic Book Bubble	20220913
    CobbleCritters	20220922
    Trailblazers	20220916
    Kinfire Chronicles: Nights Fall	20220921
    Sea of Legends: Vengeance of the Empires	20220915
    Almost Innocent	20220920
    Weavlings in the Wilds	20220929
    River Trek	20220909
    Bakufu: A Japanese Themed Strategic Card Game	20220920
    Full Sun	20220917
    Diamond Dig	20220920
    Barbaric	20220906
    Dwar7s Legendary Forest	20220921
    

    I’m sure I’m just doing something wrong in my query, but I’m following the steps listed in the docs (https://www.advancedcustomfields.com/resources/orde-posts-by-custom-fields/), and I’m seeing what I’m doing wrong. Does anyone have input?

    EDIT: I came back and added the post id for reference and it almost seems like it’s being ordered by that instead of the custom field. That reinforces my belief that I’m missing something, but I’m just not seeing it.

  • Unread

    Display only Top 4 4 columns and 1 row

    Greetings! Need help in displaying repeater fields. I need only the 4 results to fill up 4 columns and in only 1 row. These top 4 should not be null or empty. Is there such a way to filter acf repeater fields?

    Thanks!

  • Unread

    ACF File disappearing in Gutenberg on edit

    Hi I’ve made a Gutenberg block using the File field, its working and displaying correctly on the frontend, but if I go back to edit as soon as I click on the block the files are removed leaving a blank file selection.

    Not sure why it is getting wiped out each time?

  • Solved

    ACF conditional logic hide output in a foreach loop

    I am using a standard loop
    https://www.advancedcustomfields.com/resources/hiding-empty-fields/

    which outputs the field label and field values as table cells in a table.

    There are no Row Repeaters OR Field Groups with sub_fields.

    
    $out = '';
    $out .= '<div><table><tbody>';
    
    	$fields = get_field_objects();
    
    		if( $fields ){
    
    			foreach( $fields as $field ){
    			if( $field['value']){
    
    				$value = $field['value'];
    				if(is_array($value)) {
    				$value = @implode(', ', $value);
    				}
    
    				$out .= '<tr class="boat-tb-row"><td class="boat-tb-cell"><span class="acf-label">' . $field['label'] . '</span></td><td class="boat-tb-cell"><span class="acf-value">' . $value . '</span></td></tr>';
    			}
    
    		}
    
    	}
    
    $out .= '</tbody></table></div>';
    
    	return $out
    
    

    This is outputting all ACF field labels and values.

    One of the ACF fields is a checkbox list. ACF_Field_1 = checkbox array (1,2,3,4,5)

    ACF_Field_2 – Conditional logic – Show this field if [ACF_Field_1] > [value is equal to] > [4]

    Using the current for each loop, on the front end of my post, ACF_Field_2 is output on every post regardless of the conditional logic (ACF_Field_1 checkbox array does not include “4” )

    How do I account for the following in the for each loop.

    ACF_Field_1 if in_array(‘4’) include ACF_Field_2 in the foreach loop output.
    else hide ACF_Field_2 from the for each loop output

    My thought would be to php unset ACF_Field_2 from the array and run 2 seperate loops if {for each loop array_1 out . = } else { for each loop array_2 out. = }

    My understanding is that in this case I cannot use if (have_rows() while(have_rows() as this is related specifically to ACF Repeaters.

    I have been trolling Google for hours trying to find a specific case:
    Then I stumbled upon this post answer
    https://stackoverflow.com/questions/55221256/hide-certain-acf-fields-wordpress

    However, I don’t quite understand what the author has done in this answer and how to implement in the current loop.

    I’d be interested to know if there is a standard way of dealing with this in the ACF domain. As I could not find anything similar in the ACF support forum

    I am outputting the table using a [shortcode]
    Rather than having one long table, I am wanting to break apart the ACF Group into 3 [shortcodes] . . .
    [Specifications]
    [Features]
    [Options]

    I read some where there is not way to differentiate or segment fields using the ACF Layout Tab

    To achieve this am I better off
    1 – creating 3 separate Field Groups and displaying all 3 Field Groups to the Custom Post type and then segment my short codes using the Field Group Key “group_62eb60af9059d”.

    2 – Use a Layout Group ?

    3 – Naming my fields with a common denominator to differentiate sets of fields

    group1_field_name1
    group1_field_name2

    group2_field_name1
    group2_field_name2

    group3_field_name1
    group3_field_name2

    I look forward to your technical assistance.

    J 🙂

  • Helping

    Repeater field is not displaying in frontend

    Hi tried to add repeater field but it is not showing in frontend
    <?php

    if( have_rows(‘casino_data’) ):

    while( have_rows(‘casino_data’, ‘option’) ) : the_row();

    $number = get_sub_field(‘number’);
    $img = get_sub_field(‘image’);
    $name = get_sub_field(‘name’);

    echo $number;

    endwhile;

    else :

    endif;

    ?>

  • Unread

    Displaying items grouped by "custom post type categories"

    I have a custom post type called Item Category that simply contains the names of all my item categories (saved as posts) such as

    • Vehicles
    • Rental
    • Camping

    There are no ACF-related fields within this custom post type.

    I have another custom post type called Items. Here I can create items and for each individual item, I can select multiple item categories (Vehicles, Rentals, Camping) based on the ACF “Relationship” field that pulls the categories from the Item Category CPT.

    On the frontend of the website, I am wanting to display the items grouped by categories, something like this:

    Category: Vehicles

    • Item: Car
    • Item: Truck

    Category: Rental

    • Item: Car
    • Item: Tent

    Category: Camping

    • Item: Tent

    When I run a query like this:

    foreach ($posts as $key => $val):
       echo $val->post_title; // Displays item name
       print_r(get_field('category', $val->ID)); // Displays array of categories
    }

    , it simply displays items and it’s related categories.

    How do I resolve this?

  • Solving

    ACF Blocks not Rendering Correctly in Editor

    I have a number of custom blocks made with ACF’s acf_register_block_type() that are no longer displaying correctly in editor views (page/post/theme, etc). When using Preview and editing the fields in the sidebar, styling is correct. But when I change to the editor view, all styling is stripped away. It also seems like values entered into ACF fields in Edit mode do not persist, and I need to enter them while in Preview mode for them to actually be entered. Ideally I’d like to turn Preview mode off, so I had ‘mode’ set to ‘Edit’ during registration, with the ‘mode’ Supports option set to false. I’ve tried different permutations of changing these settings and nothing seems to fix it. Here’s my registration function for this specific block in case that helps.

    add_action('acf/init', 'accordion_block_type_register');
    function accordion_block_type_register()
    {
    
        // Check function exists.
        if (function_exists('acf_register_block_type')) {
    
            acf_register_block_type(array(
                'name'              => 'accordion',
                'title'             => __('UC Accordion'),
                'description'       => __('Create an accordion block with informational panels inside '),
                'category'          => 'formatting',
                'render_template'   => 'template-parts/blocks/accordion/accordion-render.php',
                'icon'              => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-archive" viewBox="0 0 16 16">
                <path d="M0 2a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1v7.5a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 1 12.5V5a1 1 0 0 1-1-1V2zm2 3v7.5A1.5 1.5 0 0 0 3.5 14h9a1.5 1.5 0 0 0 1.5-1.5V5H2zm13-3H1v2h14V2zM5 7.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"/>
              </svg>',
                'mode'              => 'edit',
                'keywords'          => array('accordion'),
                'enqueue_assets'    => function () {
                    wp_enqueue_style('uc-accordion-style', get_template_directory_uri() . '/template-parts/blocks/accordion/uc-accordion.css');
                    wp_enqueue_script('accordion-script', get_template_directory_uri() . '/template-parts/blocks/accordion/uc-accordions.js', array('jquery'), '', true);
                },
                'supports'          => array(
                    'mode'          => true,
                    'align'         => false
                )
            ));
        }
    }

    I’ve attached screenshots of each view as well. I am using WordPress 6.0 without Gutenberg plugin installed. These were all working normally earlier this week so I’m wondering if it’s related to the WordPress 6.0 update?

    Any help would be great, thanks!

  • Unread

    Displaying repeater accordian content

    Hi,

    I have created a field group and within here I have created a faq accordion repeater. I am trying to print out the contents of this repeater on my website front end but having followed various tutorials online I can’t get this to work.

    The code I am using is shown below. At present nothing is displayed. Can anyone help please?

    `<?php

    // check if the repeater field has rows of data
    if(have_rows(‘content_faqs’) ):

    echo “check”;
    // loop through the rows of data for the tab header
    while ( have_rows(‘content_faqs’) ) : the_row();

    $header = get_sub_field(‘faq_question’);
    $content = get_sub_field(‘faq_answer’);

    ?>

    <button class=”accordion”><?php echo $header; ?></button>
    <div class=”panel”>
    <p><?php echo $content; ?></p>
    </div>
    <?php
    endwhile; //End the loop

    else :

    // no rows found

    endif; ?>

  • Solved

    How to get custom field from custom taxonomy

    I am trying to retrieve a field from a custom taxonomy so that each post will have a featured image however, i cannot seem to get the field when using the field name and ID. For example,

    `foreach ($terms as $term) {
    echo $term_id;
    echo ‘<li><a href=”‘.get_term_link($term).'”>’.$term->name.'</a></li>’;
    echo get_field(‘workspace_featured_image’, “workspace_category_12”);
    echo get_field(‘workspace_featured_image’, $term->taxonomy . ‘_’ . $term->term_taxonomy_id);
    echo $term->taxonomy . ‘_’ . $term->term_taxonomy_id;

    }`

    When i run the bottom line it displays “workspace_category_number” which i believe is correct however, it is still not displaying when i use it with get_field().

    Any help would be much appreciated.

  • Solved

    Taxonomy Terms

    I want to offer content authors the ability to select Tags that I will show in the page.

    I have a layout that has a field called “resources_carousel_topic_filter_list”. The field type is “Taxonomy Terms” and I have the Allow Taxonomy to only allow “Tags” as a horizontal row of checkboxes.

    When editing the page, it looks as expected. I can select several tags.

    However, I’m having trouble displaying these selected tags. I can see that ‘resources_carousel_topic_filter_list’ “has rows”, but I cannot get the selected tags.

    while ( have_rows( 'resources_carousel_topic_filter_list' ) ) : the_row();
            // i can get here if I put a breakpoint
    endwhile;

    get_field( 'resources_carousel_topic_filter_list' ) returns null as does
    get_sub_field( 'resources_carousel_topic_filter_list' )

  • Solved

    Custom User Admin Page

    I’m building a CRM plugin and have built a tabbed set of ACF fields for editing user meta which appears on the user profile editor in the admin under user-edit.php?user_id=2. So far, so good.

    The issue I have here is that my ACF fields are buried under all the default user meta fields in which my client has no interest. What I’d like to do therefore is display just those fields on a custom admin page.

    So I have my admin menu and various admin pages including a custom table of all the users with of specific ‘client’ roles. Clicking on those clients takes you to a URL like admin.php?page=crm-client&user=2. THIS is where I’d like my ACF user fields to appear.

    I’ve gone down a whole rabbit hole of building in custom location rules but, so far as I can tell, they just don’t get hooked in on my custom admin pages so I’m thinking that I need another approach: might it be possible to somehow set-up the user object on my custom admin page and ‘trick’ acf into displaying the fields because it believes that default location rule “User role” “is equal to” “x” to be true, i.e.: that we are looking at a user?

    Any and all suggestions are welcome. I’m finding very little useful stuff online relating to customising the admin experience for editing users.

    Many thanks

  • Helping

    Custom Youtube Field Not Displaying

    Custom youtube field stopped working all of a sudden. It just shows a blank youtube iframe on the front end with an error message (An error occurred. Please try again later…).

    Also when viewing the html code, it doesn’t look like it’s getting the value of the custom field.

    <iframe src=”https://www.youtube-nocookie.com/embed/”></iframe&gt;

    Here’s our existing code:
    <?php
    global $product;
    $pp_id = $product->get_id();
    $ff = get_fields($pp_id);
    if(!empty($ff[‘youtube_section’])){
    ?>
    <iframe src=”https://www.youtube.com/embed/&lt;?= $ff[‘youtube_section’][‘youtube’];?>”></iframe>

  • Solved

    Custom image field inside product_cat taxonomy not displaying

    So, I have created a custom field inside my product categories for an image to be uploaded (I am using both the standard WP category image, as well as this second one). I need to display the field inside a loop, but am having trouble getting it to show.

    <div class="product-categories-list">
       <?php foreach( $prod_categories as $prod_cat ) {     
         $cat_thumb_id = get_term_meta( $prod_cat->term_id, 'thumbnail_id', true );
         $shop_catalog_img = wp_get_attachment_image_src( $cat_thumb_id, 'large' );
         $term_link = get_term_link( $prod_cat, 'product_cat' );
         $cat_title = $prod_cat->name; 
    
         // THIS FIELD
         $cat_term = get_queried_object();
         $hover_img = get_field('hover_image', $cat_term); 
       ?>
    
              <div class="product-category">
                <a href="<?php echo $term_link; ?>">
                  <div class="image">
                    <img class="base-image" src="<?php echo $shop_catalog_img[0]; ?>" alt="<?php echo $cat_title; ?>" />
                    <img class="hover-image" src="<?php echo $hover_img['url']; ?>" alt="<?php echo $cat_title; ?>">
                  </div>
                  <h3><?php echo $cat_title; ?></h3>
                </a>
              </div>
              
            <?php } wp_reset_query();?>
            </div>
  • Helping

    Help with displaying ACF relationship

    Hi, there. I have two custom post types: species and family.

    – In species I have this relational field “family_species” that filters by post type “family”.
    – In family post type I only have one fild (family_name);

    1 – So I created a new family called “green” and another one called “red”;
    2 – I created new ‘species’ entry called ‘alder’ (and selected ‘green’ family) and another one called ‘oak” (and selected ‘red’ family).

    I would like to display in a page a list for family (and once you click on the family name, it opens a html summary/detail with the species related to a specific family).

    – Green
    — Alder
    – Red
    — Oak

    My following code shows the families but something is not working when it comes to show only the species of each family. I’ve been trying everything for three days, but it’s not working. Can someone help me with that? thanks a lot.

        $my_args = array(
            'post_type' => 'family',
            'posts_per_page' => -1,
            'orderby' => 'title',
            'order' => 'ASC',
        );
        $my_query = new WP_Query ($my_args);
        if( $my_query->have_posts()) : while ( $my_query->have_posts() ) : $my_query->the_post();?>
        <div>
            <div>
                <details>
                    <summary><h1><?php 
                        $family_name = get_field('family_name');
                        echo $family_name; ?>></h1><p></p>
                    </summary>
                    
                    <?php
                    $args = array(
                    'numberposts'	=> -1,
                    'post_type'=> 'species',
                    'meta_query'=> array(
                    'relation'=> 'AND',
                    array(
                    'key'=> 'specie_name',
                    'value'	=> '"' . get_the_ID() . '"',
                    'compare'=> 'LIKE'
                    ),
                    array(
                    'key'=> 'family_for_this_specie',
                    'value'	=> $family_name,
                    'type'	=> '='
                    )
                    )
                    );
    
                    // query
                    $the_queryy = new WP_Query( $args );
    
                    ?>
                    <?php if( $the_queryy->have_posts() ): ?>
                    <ul>
                    <?php while ( $the_queryy->have_posts() ) : $the_queryy->the_post(); ?>
                    <li>
                    <a href="<?php the_permalink(); ?>">
                    <?php the_title(); ?>
                    </a>
                    </li>
                    <?php endwhile; ?>
                    </ul>
                    <?php endif; ?>
    
                    <?php wp_reset_query();	?>
                    
                </details>
            </div>
        </div>   
    
        <?php endwhile; endif; 
        wp_reset_query();?>
    

    Thak you so much for your attention.

  • Solved

    Very basic shortcode issue with Divi

    Hi all,

    I feel like I’ve got the most basic requirement and it’s beaten me.

    I’m using Divi and ACF.

    We have a expiry date across several pages and instead of editing each block/page manually we’re looking to save time by using a shortcode and updating one thing instead of 20 pages.

    I’ve set up a Field group, added a field, given it a title/shortcode.

    I’ve tried displaying on a single post, a single page and all pages that have a default layout.

    The idea is to have a ‘page’ with all the shortcodes at the bottom and enter the data there, that data is called on all the different pages on the site where the shortcode is used.

    I just can’t get it to work. [acf field="expirydate"] displays nothing. Needless to say there’s no typo, that’s what’s in ACF.

    At one point I had it working when in the divi builder but it never showed on a live page.

    I’ve tried so many different things, clearing the various caches along the way.

    Any ideas?

  • Helping

    Display Posts from sub-post Repeater Field

    I am having a hard time with something and hoping I can get a little assistance. Here is my goal:
    I have a web site where we put on multiple Events in various locations which inlcude Artist Instructors (primarily musicians) which change every year. We want to be able to provide a page where someone can go and see who taught at each location/year combo. Or to filter the list. I believe I need to do the following to make this work:

    • Have a Primary “Festival” page which has some information which can be over-written each year. Include metadata via ACF for the Location (A Clone field from the Overview post below so I do not have to edit Locations in multiple places) and the current Year (date picker formatted as YYYY only) we are registering people for.
    • Have a Post for each Artist wich is a Biography and includes an ACF field for their “Instrument”
    • Have an Overview Post which includes detailed information for teh current Year and a Repeater field for selecting Post Objects for the Biographies. I am using the Repeater field so we can set the Order in which the Biographies appear. This Overview post has ACF fields for
    • Location
    • Start Date (date picker)
    • End Date (date picker)
    • Artists (Repeater with a Post Object Subfield called Artist)
    • So Iam trying to create a Template for the Main Page. I can pull the appropriate Overview Post, but I am not getting the Artist Posts (Biographies) to display. I get the Title as a link for the First of Three in the list. After that I get 23 listings with no Title/Link and only the text for teh custom field with no entry (actually a foreach error but that is likely because some other data is being returned). Any idea where I may be off on this?

      Code:

      <?php
      /**
       * The template for displaying the primary festival location pages
       *
       * Template Name: Festival Main
       * 
       * @package WordPress
       * @subpackage Boxwood\\
       * @since Twenty Twelve 1.0
       */
      get_header();
      ?>
      	<div id="container">
      		<div id="content">
      			<div id="main-column-full-width">
      				<?php /* The entry content */ ?>
      				<div class="entry-content">
      					<?php if(!is_front_page()) {?>
      						<?php if ( function_exists('yoast_breadcrumb') ) {
      							yoast_breadcrumb('<p id="breadcrumbs">','</p>');
      						} ?>
      						<h1 class="entry-title"><?php the_title(); ?></h1>
      					<?php }?>
      
      					<?php
                          if (have_posts()) :
                              while (have_posts()) :
                                  the_post();
      						    the_content();
      					    endwhile;
      					endif;
      					?>
      
      <h1>Start Latest</h1>
      
      <?php
      /**
       * Get the Overview Post to pull data for retrieving other posts, etc
       */
      $my_location = get_field('location_location');
      $my_year = get_field('year');
      
      $startyear = $my_year . '0000';
      $endyear = $my_year + 1 . '0000';
      
      $args = array(
          'numberposts'	=> -1,
          'post_type' => 'post',
          'category_name' => 'festival-overview',
          'meta_query' => array(
              array(
                  'key'     => 'location',
                  'value'   => $my_location,
              ),
            array(
              'key' => 'start_date',
              'value' => $startyear,
              'compare' => '>'
            ),
            array(
              'key' => 'start_date',
              'value' => $endyear,
              'compare' => '<'
            )
          )
      );
      $overview_posts = new WP_Query( $args );
      
      // Show the Overview Post content
      if ( $overview_posts->have_posts() ) :
          while ( $overview_posts->have_posts() ) :
              $overview_posts->the_post();
                  
              // Check rows exists.
              if( have_rows('artists') ):
                  // Loop through rows.
                  while( have_rows('artists') ) : the_row();
      
                      // Load sub field value.
                      $featured_posts = get_sub_field('artist');
                      if( $featured_posts ): ?>
                          <ul>
                              <?php foreach( $featured_posts as $post ): 
              
                                  // Setup this post for WP functions (variable must be named $post).
                                  setup_postdata($post); ?>
                                  <li>
                                      <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                      <span>A custom field from this post:
                                          <?php
                                              $my_instrumentsarray = get_field('intruments');
      	                            	    foreach ($my_instrumentsarray as $my_instrument) {
                      	                        echo $my_instrument ;
                      	                } ?>
                      	            </span>
                                  </li>
                              <?php endforeach; ?>
                          </ul>
                          <?php 
                          // Reset the global post object so that the rest of the page works correctly.
      //                    wp_reset_postdata();
                      endif;
               endwhile;
              endif;
          endwhile;
      
          while ( $overview_posts->have_posts() ) :
              $overview_posts->the_post();
                  if ( has_post_thumbnail() ) :
                      the_post_thumbnail();
                  endif;
                  ?>
                  <div class="entry-content">
                      <?php the_content(); ?>
                  </div>
              </article>
              <?php
          endwhile;
      
      endif;
      
             
      // Restore original post data.
      wp_reset_postdata();
      
      ?>
      
      				</div><!-- .entry-content -->
      			</div><!-- #main-column-full-width -->
      		</div>
      	</div><!-- #container -->
      	
      	<?php get_footer(); ?>
  • Solved

    ACF Conditional dokan issue

    Hello there,

    I have browsed many threads and different sides to get this solved but with no solution so far.

    We have a wordpress installation working with WooCommerce and Dokan.
    Within our marketplace we want to seperate 2 different main categories with ACF PRO.

    So basically we want to add different fields for each category.

    If a vendor chooses for example category “Industry” then 3 new fields should appear in the product creation page as well as on the product page itself after publishing the product.

    If the vendor chooses category “Private” there should be 3 different fields than there would be when using category “Industry”.

    Vendor Edits are allowed.

    Right now, only in our backend this is working. When we as the admin create/edit a product the condition works perfectly fine and is also displayed on the page correctly.

    Where it is not working is when the vendor creates/edits a product on front end. In the product creation page there are all fields shown no matter what category is chosen.

    This is the code we used for displaying the fields on the product page:

    add_action( ‘woocommerce_product_meta_end’, ‘acf_dokan_display_product_fields4’ );
    function acf_dokan_display_product_fields4(){
    echo ‘<p class=”productpdf”> <b>Model:</b> ‘ . get_field(‘model’, $post_id, true) . ‘ </p>’;
    }

    add_action( ‘woocommerce_product_meta_end’, ‘acf_dokan_display_product_fields5’ );
    function acf_dokan_display_product_fields5(){
    echo ‘<p class=”productpdf”> <b>Kategorie:</b> ‘ . get_field(‘kategorie’, $post_id, true) . ‘ </p>’;
    }

    add_action( ‘woocommerce_product_meta_end’, ‘acf_dokan_display_product_fields’ );
    function acf_dokan_display_product_fields(){
    echo ‘Produkt PDF Herunterladen‘;
    }

  • Unread

    Error when using options in blocks

    I’m getting an error whenever I try to use the value from an options screen for a block.

    I register the options with acf_add_local_field_group.

    I register the block with acf_register_block_type.

    If I try to retrieve the value of an options field when I’m initializing my block I get this error, but only on the screen that has the options field. I don’t get this error on the front-end when displaying the block, or on the back-end when editing pages that contain the block.
    Notice: Undefined index: rows in C:\Users\Eli\Local Sites\globalplugin\app\public\wp-content\plugins\advanced-custom-fields-pro\includes\fields\class-acf-field-textarea.php on line 57

    The error changes according to the type of field but it’s always similar.

    Any ideas of what to check? I’ve thought of detecting if it’s an options screen and not have the block use the options field in that case, but that seems kludgy.

  • Unread

    Subfield in a loop not displaying

    I’m displaying a loop of custom post type. The custom fields are displaying correctly, however I can’t get the subfields to display.

    In this case I’ve created a custom field named project_description with a subfield called sub_heading within a group called Project Page.

    This is what I’ve done so far. Can anyone tell me what I’m doing wrong?

    <section class="services-section">    
                      <div class="container services-section-container">
                         <h1 class="fp-header extended-black-l">Featured Projects</h1>  
                         
                         <?php 
                          $featuredProjectSection = new WP_Query(array(
                            'posts_per_page' => 10,
                            'post_type' => 'project'
                          ));
    
                          while($featuredProjectSection->have_posts()) {
                          $featuredProjectSection->the_post(); $i++; if(($i % 2) == 0) { ?>
                       
                            <div class="row splitcontent-services">
                              <div class="col-lg-6 col-6 services-img-left">
                                <img src="<?php the_field('top_image') ?>">
                                             
                              </div>
                              
                              
                              <div class="col-lg-6 col-6 services-content-right">                         
                                <h2 class="condensed-semibold-l"><?php the_title(); ?></h2>
                                  <?php if( have_rows('project_description') ): ?>
                                  <?php while ( have_rows('project_description') ) : the_row(); 
                                   $subhead = get_sub_field('sub_heading');?>                             
                                <h3 class="regular-m"><?php echo $subhead; ?></h3>
                                <?php endwhile; ?>
                                <?php endif; ?>
    
                                <button class="extended-black-s"><a href="<?php the_permalink(); ?>">Learn More ></a></button>
                                	
                              </div> 
                            </div>
Viewing 25 results - 51 through 75 (of 508 total)