Support

Account

Home Forums Search Search Results for 'field not displaying'

Search Results for 'field not displaying'

topic

  • Solving

    Field type for displaying text/links with post_id variable

    I need a way to display some additional stuff conditionally within the field Metabox.

    Is there an add-on that does this?

    I found one called Read Only but it doesn’t seem to actually work.

    Basically when one field has a certain value I wanted to show a link to another admin page with the post ID ideally inserted into the link. I can maybe just make something of my own but if something already exists I figured I’d ask that first.

  • Solved

    How to select multiple options from specific repeater row?

    I am trying to display multiple select values on the frontend.

    This code currently works when the multi-select option is turned off, and correctly display images for one field that is selected without issue. However, nothing works for multi fields when I turn the option on (no matter how many are selected).

    Can anyone spot what’s missing?

    functions.php:

    function acf_load_college($field)
    {
    	$field['choices'] = array();
    
    	if (have_rows('gallery_repeater', 'option')) {
    		while (have_rows('gallery_repeater', 'option')) {
    			the_row();
    
    			$value = get_row_index();
    			$label = get_sub_field('college');
    			$field['choices'][$value] = $label;
    		}
    	}
    	return $field;
    }
    add_filter('acf/load_field/name=choices', 'acf_load_college');
    add_filter('acf/settings/row_index_offset', '__return_zero');
    

    Displaying on frontend:

    <?php
    		$field = get_field_object('choices');
    		$value = $field['value'];
    
    		$rows = get_field('gallery_repeater', 'option');
    		$specific_row = $rows[$value]; //dumping this returns null when multi-select option is turned on, but returns correct repeater array for selected value when multi-select is off
    
    		$sub_field_value = $specific_row['gallery'];
    		?>
    
    	<?php foreach ($sub_field_value as $img) : ?>
    	   <div data-src="<?php echo esc_url($img['sizes']['large']); ?>" title="<?php echo esc_attr($img['title']); ?>">
    		<img src="<?php echo esc_url($img['sizes']['large']); ?>" alt="<?php echo esc_attr($img['alt']); ?>" title="<?php echo esc_attr($img['title']); ?>" />
    		</div>
            <?php endforeach ?>
    	</div>
    </div>
  • Solved

    Querying by Taxonomy field and separating by one such taxonomy

    I’m trying display specific custom post types by taxonomy on specific pages, and I’m attempting to follow in the footsteps of the advice found here: https://support.advancedcustomfields.com/forums/topic/query-posts-via-taxonomy-field/

    I’ve associated the custom post type taxonomies with the pages via the Taxonomy ACF field, and I’ve got that working fine.

    However I’m wondering if it’s possible make it so that I can divide the out put up by those taxonomies, similar to the solution found here:https://wordpress.stackexchange.com/a/40117

    But I can’t seem to successfully figure out how to marry the two concepts, so that the end result is that I’m only displaying the specific custom posts that relate to the taxonomies that I’ve selected on the target page via the Taxonomy field, separated by one of those taxonomies.

    Below is my unsuccessful attempt:

    
    <?php
    $post_id = $post->ID;
    $domains = get_field('matrix_domain', $post_id);
    $grades = get_field('matrix_grades', $post_id);
    if (!is_array($domains)) {
        $domains = array($domains);
      }
    if (!is_array($grades)) {
        $grades = array($grades);
      }
    
    $terms = get_terms( array(
      "taxonomy" => "math_grades",
    ) );
    foreach ($terms as $term) : 
      $posts = get_posts( array(
                    'post_type'         => 'math_matrix',
                    'posts_per_page'    => -1, //important for a PHP memory limit warning
                    'tax_query' => array(
    'relation' => 'AND',
          array(
            'taxonomy' => 'math_domains',
            'terms' => $domains,
          ),
          array(
            'taxonomy' => 'math_grades',
            'terms' => $grades,
          ),
                    ),
                ));
    ?>
      <h4><?= $term->name; ?></h4>
            <div class="matrix-labels"><div class="standard-label">Standard</div><div class="can-label">Can the student:</div><div class="cannot-label">If not:</div><div class="resource-label">Additional Resource</div></div>
    <ul class="matrix-search">
      <?php foreach($posts as $post) : ?>
    <li><div class="matrix-standard"><div class="mobile-label">Standard</div><?php global $post;
    $standards = wp_get_post_terms($post->ID, 'math_standards', array("fields" => "names"));
    if (count($standards) > 0)
    {
        echo implode(', ', $standards);
    }; ?></div>
           <div class="matrix-title"><div class="mobile-label">Title</div><?php the_title(); ?></div>
           <div class="matrix-action"><div class="mobile-label">Action</div><a>" target="_blank"><?php echo esc_html($actionsTitle); ?></a></div>
           <div class="matrix-resource"><div class="mobile-label">Additional Resource</div><a>" target="_blank"><?php echo esc_html($resourcesTitle); ?></a></div>
    </li>
      <?php endforeach; ?>
      </ul>
    <?php endforeach; ?>
    
    <?php
    $post_id = $post->ID;
    $domains = get_field('matrix_domain', $post_id);
    $grades = get_field('matrix_grades', $post_id);
    if (!is_array($domains)) {
        $domains = array($domains);
      }
    if (!is_array($grades)) {
        $grades = array($grades);
      }
    $_terms = get_the_terms( $post_id , 'math_grades' );
    
    foreach ($_terms as $term) :
    global $post; 
        $_posts = new WP_Query( array(
                    'post_type'         => 'math_matrix',
                    'posts_per_page'    => -1, //important for a PHP memory limit warning
                    'tax_query' => array(
    'relation' => 'AND',
          array(
            'taxonomy' => 'math_domains',
            'terms' => $domains,
          ),
          array(
            'taxonomy' => 'math_grades',
            'terms' => $grades,
          ),
                    ),
                ));
    
        if( $_posts->have_posts() ) : ?>
    
     <h3 class="grade"><?php echo $term->name; ?></h3>
            <div class="matrix-labels"><div class="standard-label">Standard</div><div class="can-label">Can the student:</div><div class="cannot-label">If not:</div><div class="resource-label">Additional Resource</div></div>
    <ul class="matrix-search">
            <?php while ( $_posts->have_posts() ) : $_posts->the_post();
            ?>
    <li><div class="matrix-standard"><div class="mobile-label">Standard</div><?php global $post;
    $standards = wp_get_post_terms($post->ID, 'math_standards', array("fields" => "names"));
    if (count($standards) > 0)
    {
        echo implode(', ', $standards);
    }; ?></div>
           <div class="matrix-title"><div class="mobile-label">Title</div><?php the_title(); ?></div>
           <div class="matrix-action"><div class="mobile-label">Action</div><a>" target="_blank"><?php echo esc_html($actionsTitle); ?></a></div>
           <div class="matrix-resource"><div class="mobile-label">Additional Resource</div><a>" target="_blank"><?php echo esc_html($resourcesTitle); ?></a></div>
    </li>
            <?php
            endwhile;
    
            echo '</ul>';
    
        endif;
        wp_reset_postdata();
    
    endforeach;
    ?>
    
  • Unread

    Difficulty displaying Taxonomy Values

    Hi all,

    I’m tearing my hair out over this. I’m staring at my code trying to work out where I’m going wrong, and I’m having difficulties picking it.

    I’m trying to update the sidebar of my theme to display the contents of the fields I have set up. The logic I’m trying to set up is that it only displays details about a field if it contains a value, and ignore empty fields. I’ve got that working with the URL fields and Text fields. However I’m having issues with the Taxonomies.

    I’m using the following code:

    $terms = get_field( "genre", $post_id );
    if( $terms ) {
        echo "<b>Genre:</b> ";
        foreach( $terms as $term ) :
            echo esc_html( $terms->name );
        endforeach;
        echo "<br />";
    }

    The issue that I’ve got is that it displays the “Genre:” label, so it is obviously correctly picking up a value. IT doesn’t actually display the value of the field though.

    I was attempting to base this off https://www.advancedcustomfields.com/resources/taxonomy/ to try and work out how to use this correctly.

    I’m tearing my hear out trying to work out what I’m doing wrong. I’m sure it’s something dead simple that I’m not getting out of frustration. Hopefully somebody is able to offer some pointers as to what I’m doing wrong.

  • Solved

    Code Field / Return value of another custom field in post edit

    Hi,

    I would like to display the value from a custom field of another post (an option pages, actually) in my custom post type edit page.Β 

    The corresponding value would be displayed in a repeater field, and would be dynamic (it would depend on the value entered in the first column).

    The value returned doesn’t even have to be edited, so it should be simply about displaying “get_field”, but I don’t know how to do that for the back end?Β 

    I tried creating a “message” custom field and add the corresponding code, but the message field doesn’t work with php (nor shortcodes).Β 

    There is this plugin to add code but it looks abandoned (i don’t even know if it works) :Β https://wordpress.org/plugins/advanced-custom-fields-code-area-field/

    How could I solve this ? Thank you !

  • Solving

    How to display post data from another page?

    Hello there I have a home page (ID=8) where I have the following displaying an article title from another post object:

    <h5 class=”card-title”><?php echo $front_page_education_section_related_post->article_title ?></h5>

    I am trying to figure out how I can now reference that from a different page?

    I see from the documentation that his example will display a field value from the post with an ID of 123:
    <p><?php the_field(‘field_name’, 123); ?></p>

    However, I have been struggling to do the same with the field I am trying to show from another page. I did trying something like the following which includes the homepage ID.

    <h5><?php the_field(‘front_page_education_section_related_post->article_title’, 8); ?></h5>

    Thanks for any help anyone might be able to provide here. I am new to php.

  • Solved

    List of Users – Filtered by an ACF field

    Hello,

    Our WP users all belong to a local “Club”. The goal is to have a section on the website that displays each club and also lists all users that are associated with that particular club.

    I have not been successful in displaying a filtered user list based on their club affiliation, I only seem to be able to display the entire user list.

    For the Club listing, I have a Custom Post Type and also a group of ACF fields that accept details, such as location and contact information. That part is working fine!

    To associate WP users with those clubs, I have set up an ACF relationship field. The field is programmed to display on the User’s form so that I can go to any user and select the club that they belong to. This is also working fine!

    The problem comes in when I try to display a list of filtered users.

    My current approach is to use a widget called Dynamic Users made by Dynamic OOO. It allows for user display and filtering by criteria such as “User Field Filters” and “Meta Value”. In the “User Field Filters,” it successfully finds my ACF relationship field, but it does not filter the list.

    Any ideas on how to troubleshoot this?

  • Solving

    fields are not displaying in custom Query in an ACF Block

    I’m trying to query some posts in an ACF Block. The same code is working properly used on the single.php, but even if I use exactly the same code provided under query-posts-custom-fields it just displays the the_title(), the_content()… but nothing from acf.

    Where does it stuck, why is it not working within a block?

    Thanks for any help πŸ™‚

    <?php
        $args =  array(
            'orderby' => 'menu_order',
            'order' => 'ASC',
            'post_status' => 'publish',
            'post_type' => 'post',
        ) ;
         
    // query
    $the_query = new WP_Query( $args );
    if( $the_query->have_posts() ): 
        while( $the_query->have_posts() ) : $the_query->the_post(); 
            $veranstaltung = get_field('anzeigeorte');
            if( get_field('veranstaltung') && $veranstaltung && in_array('aktuelles', $veranstaltung) ) { ?>
                <a href="<?php the_permalink(); ?>" class="preview veranstaltung-preview">
                    <h3><?php the_title(); ?></h3>
                    <p class="date"><?php the_field( 'datum'); ?></p>
                    <p><?php the_field( 'kurzbeschreibung'); ?></p>
                </a>
            <?php } 
    
            elseif ( ! get_field('veranstaltung') ) { ?>
            <a href="<?php the_permalink(); ?>" class="preview post-preview">
                <h3><?php the_title(); ?></h3>
                <?php the_excerpt(); ?> 
            </a>
        <?php }
    	endwhile; 
    endif; ?>
    
    <?php wp_reset_query();	 // Restore global post data stomped by the_post(). ?>
  • Unread

    Google Map not displaying in WP backend

    This issue https://support.advancedcustomfields.com/forums/topic/google-map-not-displaying-on-wp-backend/ has been open for nearly 3 years and is marked “solving”. It is however closed to new replies.

    As far as I can tell, adding an API key through the methods suggested does not add the API key to the request to googleapis. It has nothing to do with billing or new versions of Google Maps or the validity of the key: the key is simply never attached to the request.

    What is the status of the fix?

  • Solving

    Did not work to display

    Nothing appears on the page. I tried very easy tests from youtube.
    I created a Custom field with my page where I replace the Header and Subtitle.

    I replaced in the template where it says title with:
    <?php the_field('title');?>

    But nothing is displaying…

    I don’t understand where I went wrong.
    I chose where to apply the changes, I also chose a page. I followed every step of the video.

  • Helping

    Display File Name in Dashboard Listing

    I have a Resources CPT with ACF to gather additional information. One of the fields is a File field. I want to display the File name in the Dashboard listing. The code I’m using doesn’t work (not expecting it to either for this application). It is displaying the record ID. What is the correct code to ouput the File name to the Dashboard listing?

    Here is a screenshot of the Dashboard listing:

    https://share.getcloudapp.com/Blu48jmd

    Here are the settings in ACF:

    https://share.getcloudapp.com/L1udjGwY

    Here is my code:

    https://share.getcloudapp.com/X6uePkyG

    Thanks

  • Helping

    Image not displaying

    Hi All,

    I’ve created a very simple image variable for a WordPress project:

    <div class="container blog_info">
     <?php
    	while(have_posts()) {
    		the_post();?>
    		<div class="post-item">
    			<div class="post-image"><img src="<?php echo $post_image ?>"></div>
    			<h2 class="blog_heading">
    			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    			<?php the_excerpt(); ?>
    			<a class="btn-blog" href="<?php the_permalink(); ?>">More &raquo;</a>
    		</div>
    	<?php }
     ?>
    </div>

    For some reason the selected image does not display:

    <?php echo $post_image ?>
    <?php $post_image = get_field(“post_image”); ?>

    I’m obviously missing something! Thanks in advance πŸ™‚

  • Helping

    Images not showing

    Hi there!
    I have an issue with displaying icons. One (the last one) is showing but others are not. Image is set as an array.
    in code it’s set like this:

    
    $card1 = get_field('card_1');
    <?php echo esc_url( $card1['icon']['url']); ?>
    

    Only card4 is showing the image and if, for example, card1 i renamed to card4 it works properly.
    Code is copy/pasted.

    Where is the issue?

    Thanks

  • Unread

    Displaying contents from sub fields within group from outside the loop

    Hi,

    Hope everyone are well and safe.
    I need some help on displaying contents from the sub fields that were created within the group field “customers_information“.
    The contents will be shown in the single.php page, under footer section.
    With that, my first impression is to use WP_Query, to set query to my post,

    <?php $cpost = new WP_Query(array(
    'post_type' => 'post'
    ));

    And loop through the post and the group field, like below.

    if( $cpost->have_posts() ) : while( $cpost->have_posts() ) : $cpost->the_post();
    if( have_rows('customers_information') ):
    while( have_rows('customers_information') ): the_row();
    ?>

    And then call out the sub fields (video, success_summary, podcast) like below.

    <a href="<?php the_sub_field('video') ?>" class="mfp-iframe video">
    <img src="<?php bloginfo( 'template_directory' ); ?>/images/icon_video.svg" alt="Icon">
    <p>Watch the Video</p>
    </a>
    
    <a href="<?php the_sub_field('success_summary'); ?>" target="_blank" class="case">
    <img src="<?php bloginfo( 'template_directory' ); ?>/images/icon_casestudy.svg" alt="Icon">
    <p>Read the Case Study</p>
    </a>
    
    <a href="<?php the_sub_field('podcast') ?>" target="_blank" class="podcast">
    <img src="<?php bloginfo( 'template_directory' ); ?>/images/icon_podcast.svg" alt="Icon">
    <p>Listen to the Podcast</p>
    </a>

    Unfortunately, it resulted the system to run through the whole database and display all the contents.
    However, this is not what I want.
    I only need the contents that were inserted in that individual post.
    Meaning, if I have 5 posts, the single page footer will only show either one of the post contents, and not all 5.

    Can anyone please give a helping hand to light me up with some solutions?
    Your help will be much appreciated.
    Thank you.

    Danc

  • Solving

    custom field group not displaying in wp query loop for a custom post

    I cannot figure out why this loop won’t show the ACF custom field testimonial_content on the front-end. Any ideas? Thanks.

    
    	echo	'<div class="grid grid-3">';
    
    				$args = array(
    					'posts_per_page' => -1,
    					'post_type' 			=> "testimonial",
    					'post_status' 		=> "publish",
    				);
    
    						//loop
    						$testimonials = new WP_Query($args);
    
    						while($testimonials-> have_posts()): $testimonials->the_post(); ?>
    
    							<div>
    									<?php if( get_field('testimonial_content') ): ?>
        									<p class="swd_testimonial_content"><?php the_field('testimonial_content'); ?>
    
    									<?php endif; ?>
    
    							</div>
    
    						<?php endwhile;
    						wp_reset_postdata();?>
    			</div>
    
  • Unread

    Help for a beginner please !

    Hi,
    I am not develloper and i dont get where to use this ??

    https://www.advancedcustomfields.com/resources/displaying-custom-field-values-in-your-theme/

    I dont get this doc at all!

    All values are saved as native post_meta (when saved to a post) and although you can use the native WP function get_post_meta(), it is better practice to use the relevant ACF function such as get_field(). Why? Because ACF will format the value depending on the field type and make development quicker and easier!

    To retrieve a field value as a variable, use the get_field() function. This is the most versatile function which will always return a value for any type of field.

    To display a field, use the the_field() in a similar fashion.

    Here’s a basic usage example, and please be sure to view the code example page for more.

    This …. ?? How to use it??

    <?php

    /**
    * Template Name: Home Page
    */

    get_header();

    ?>

    <div id=”primary”>
    <div id=”content” role=”main”>

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

    <h1><?php the_field(‘custom_title’); ?></h1>

    ” />

    <p><?php the_content(); ?></p>

    <?php endwhile; // end of the loop. ?>

    </div><!– #content –>
    </div><!– #primary –>

    <?php get_footer(); ?>

    I just want simply display fields + Prepend and Append. Ho to do that ??
    Can you please use a non-developper language to explain ??

  • Solving

    Repeater field not working in archive-product.php

    Hello!

    I am trying to create an FAQ repeater to my archive-product.php (category pages) in WooCommerce + Storefront but unfortunately, it’s not working. It skips right over the “if” statement and just says “Come back later”. Am I missing something here since I’ve never come across an issue like this and didn’t find a solution for this from anywhere else?

    Full code of the template:

    <?php
    /**
    * The Template for displaying product archives, including the main shop page which is a post type archive
    *
    * This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
    *
    * HOWEVER, on occasion WooCommerce will need to update template files and you
    * (the theme developer) will need to copy the new files to your theme to
    * maintain compatibility. We try to do this as little as possible, but it does
    * happen. When this occurs the version of the template file will be bumped and
    * the readme will list any important changes.
    *
    * @see https://docs.woocommerce.com/document/template-structure/
    * @package WooCommerce\Templates
    * @version 3.4.0
    */
    
    defined( 'ABSPATH' ) || exit;
    
    get_header( 'shop' );
    
    /**
    * Hook: woocommerce_before_main_content.
    *
    * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
    * @hooked woocommerce_breadcrumb - 20
    * @hooked WC_Structured_Data::generate_website_data() - 30
    */
    do_action( 'woocommerce_before_main_content' );
    
    ?>
    <header class="woocommerce-products-header">
    <?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
    <h1 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h1>
    <?php endif; ?>
    
    <?php
    /**
    * Hook: woocommerce_archive_description.
    *
    * @hooked woocommerce_taxonomy_archive_description - 10
    * @hooked woocommerce_product_archive_description - 10
    */
    do_action( 'woocommerce_archive_description' );
    ?>
    </header>
    <?php
    if ( woocommerce_product_loop() ) {
    
    /**
    * Hook: woocommerce_before_shop_loop.
    *
    * @hooked woocommerce_output_all_notices - 10
    * @hooked woocommerce_result_count - 20
    * @hooked woocommerce_catalog_ordering - 30
    */
    do_action( 'woocommerce_before_shop_loop' );
    
    woocommerce_product_loop_start();
    
    if ( wc_get_loop_prop( 'total' ) ) {
    while ( have_posts() ) {
    the_post();
    
    /**
    * Hook: woocommerce_shop_loop.
    */
    do_action( 'woocommerce_shop_loop' );
    
    wc_get_template_part( 'content', 'product' );
    }
    }
    
    woocommerce_product_loop_end();
    
    /**
    * Hook: woocommerce_after_shop_loop.
    *
    * @hooked woocommerce_pagination - 10
    */
    do_action( 'woocommerce_after_shop_loop' );
    } else {
    /**
    * Hook: woocommerce_no_products_found.
    *
    * @hooked wc_no_products_found - 10
    */
    do_action( 'woocommerce_no_products_found' );
    }
    ?>
    <div class="container FAQ">
    <div class="row">
    <div class="col-md-12">
    <?php if( have_rows('faq') ):
    $i = 1; // Set the increment variable
    
    ?>
    <div id="accordion">
    <?
    // loop through the rows of data for the tab header
    while ( have_rows('faq') ) : the_row();
    ?>
    
    <div class="card" itemscope itemprop="mainEntity" itemtype="https://schema.org/Question">
    <div class="card-header" id="heading-<?php echo $i;?>">
    <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapse-<?php echo $i;?>" aria-expanded="true" aria-controls="collapse-<?php echo $i;?>">
    <span class="accordion-title" itemprop="name"><?php the_sub_field('question'); ?></span>
    </button>
    </div>
    
    <div id="collapse-<?php echo $i;?>" class="collapse" aria-labelledby="heading-<?php echo $i;?>" data-parent="#accordion">
    <div class="card-body" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer">
    <span itemprop="text"><?php the_sub_field('answer'); ?></span>
    </div>
    </div>
    </div>
    
    <?php $i++; // Increment the increment variable
    
    endwhile; //End the loop
    
    ?>
    </div>
    <?php
    else :
    
    // no rows found
    echo 'Come back later';
    endif;?>
    </div>
    </div>
    </div>
    
    <?php
    
    /**
    * Hook: woocommerce_after_main_content.
    *
    * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
    */
    do_action( 'woocommerce_after_main_content' );
    
    /**
    * Hook: woocommerce_sidebar.
    *
    * @hooked woocommerce_get_sidebar - 10
    */
    do_action( 'woocommerce_sidebar' );
    
    get_footer( 'shop' );
  • Solving

    Position 9 posts in grid based on Options page & Have timed posts work

    Hi there,

    We are running a news blog. At the top of the page, there is a featured section. This section contains 9 positions.

    I would like to control this section from one page, so an ACF option page comes to mind.

    So I have a loop that looks at the option page, and if the 9 positions have a published post ID, then they get displayed.

    
    $top1 = get_field('kiemelt1', 'option');
    $top2 = get_field('kiemelt2', 'option');
    $top3 = get_field('kiemelt3', 'option');
    $top4 = get_field('kiemelt4', 'option');
    $top5 = get_field('kiemelt5', 'option');
    $top6 = get_field('kiemelt6', 'option');
    $top7 = get_field('kiemelt7', 'option');
    $top8 = get_field('kiemelt8', 'option');
    $top9 = get_field('kiemelt9', 'option');
    
    $top1pozicio = get_posts(array(
        'posts_per_page' => 1,
        'post_type' => array('cikkek', 'mti'),
        'orderby' => 'date',
        'order' => 'DESC',
        'post__in' => $top1
    ));
    
    if ($top1pozicio): ?>
    
    <?php foreach ($top1pozicio as $post):
    
        setup_postdata($post);
    
        ?>
    <article class="item-main col-12">
        <div class="item-inner-main">
            <div class="image-blocks-main">
                <a href="<?php the_permalink(get_the_id());?>"><?php echo get_the_post_thumbnail(get_the_id(), 'medium-hd', array( 'class' => 'main_topone_featured_image')); ?></a>
            </div>
            <div class="text-holder-main">
                <h2 class="entry-title-main kiemelt1"><a href="<?php the_permalink(get_the_id());?>"><?php echo get_the_title(get_the_id()); ?></a>
                </h2>
            </div>
        </div>
    </article>
    
    <?php endforeach;
    wp_reset_postdata();
    endif;
    $top2pozicio = get_posts(array(
        'posts_per_page' => 1,
        'post_type' => 'cikkek',
        'orderby' => 'date',
        'order' => 'DESC',
        'post__in' => $top2
    ));
    
    if ($top2pozicio): ?>
    
    <?php foreach ($top2pozicio as $i => $post):
    setup_postdata($post);?>
    
    <!-- TOP2 -->
    <article class="item-main-half col-6 ">
        <div class="item-inner-main">
            <div class="image-blocks-main top2row">
                <a href="<?php the_permalink(get_the_id());?>"><?php echo get_the_post_thumbnail(get_the_id(), 'owl-size'); ?></a>
            </div>
            <div class="text-holder-main">
                <h2 class="entry-title-main"><a href="<?php the_permalink(get_the_id());?>"><?php echo get_the_title(get_the_id()); ?></a>
                </h2>
            </div>
        </div>
    </article>
    
    <?php endforeach;
    wp_reset_postdata(); 
    endif;

    So this goes on until position 9, no point in posting the entire code.

    However, there are two issues.

    1. I can’t schedule articles, because if I overwrite one of the positions with a scheduled article, the position remains empty until the new scheduled article is set to publish.

    2. All of these positions are separate loops, so they can’t roll over and replace… empty positions (for example posts that are scheduled but not yet published) so that the layout does not break.

    The goal would be something like this:

    Have the 9 positions always filled up based on the most recent posts, but overridable by the options page. Example: I have 9 articles based on the date displaying in the positions, but the news comes in that an asteroid is heading towards earth, and I deem it so that this news deserves position 3.

    The result ->

    Position 9 falls out of the loop (since it’s the oldest). Position 3 is moved to position 4 (it does not get deleted only moves +1 position in the loop, this is the most challenging part that I can’t figure out), and my great asteroid article takes up position 3.

    Is this possible?

    Can this be made to work somehow? Any pointers appreciated!

  • Unread

    Difficulties displaying ACF fields from another post

    Hi,
    We are looking to find the simplest path to displaying Custom Field content from an origin page “A” into a destination page “B”.

    The documentation referenced below, indicating the use of shortcodes seemed like the perfect answer: [ acf field="field name" post_id="123" ] found in
    https://www.advancedcustomfields.com/resources/shortcode/ … it works beautifully and without requiring any PHP coding skills!

    .. until we realised the limitation: Only works for simple text based values – NOT Shortcodes. ie. the ‘acf field’ Shortcode instead of picking up “A” based content, will pick up the ACF content from “B” destination page :-/.

    Is there any way the back end can be set up easily to have ACF fields display remote field full ‘shortcoded’ content. Would this not be the holy grail for the users who cannot easily go through a steep coding learning curve in PHP?

  • Solving

    Previewing problem with custom fields

    Hi,

    I don’t know whether the problem described below is related to Gutenberg, ACF or Elementor. So, I’m reporting it to all sides.

    I have created CPTs to which some custom fields are attached via ACF. The authors create custom posts, edit them in Gutenberg (they are not allowed to use Elementor) and fill in the custom fields. Each of these CPTs is handled by a corresponding Elementor model. This model dynamically retrieves the contents of the custom fields and display them.

    Problem
    While the posts are in draft mode in Gutenberg, previewing in Gutenberg is working fine. As soon as the post has been published, previewing in Gutenberg is no longer working correctly : all the elements displaying the custom field contents are empty in the preview. Switching back to draft mode makes the problem disappear.

    However, the post is always displayed correctly in any case for the site visitors. Only the previewing doesn’t work.

    I don’t understand where the problem could be.

    Any idea ?

    Thanks in advance.

    Patrick

  • Unread

    Block displaying another page's block?

    I have a custom block called ‘featured-content-row’.

    I want to pull the content from that block on another page into this page, i/e about page content to home page blocks.

    I’ve setup a block called ‘featured-content-row-pull’ where you can choose a pages ID as well as a title element from the block I’m targeting. This is to ensure it doesn’t show all elements of that pages blocks, just the one i want.

    It runs fine with the following…

    <?php 	
    //Vars
    $page_choice = get_field( 'page_choice' ); 
    $page_choice_row_title = get_field( 'page_choice_row_title' ); 
    
    $post_id = $page_choice ;
    $row_title = $page_choice_row_title;
    $post = get_post($post_id);
    $blocks = parse_blocks($post->post_content);
    
    foreach($blocks as $block){
    
    	if( $block['blockName']  == 'acf/featured-content-row' &&  $block['attrs']['data']['site_row_title'] == $row_title ){
    		echo render_block($block);
    	}
    } 
    ?>

    However, i get the following notice…

    Notice: Undefined index: id in /local:5757/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php on line 395

    I’m assuming this is because a block is appearing within a block and it doesn’t like the mixing of IDs anything i can do?

  • Unread

    get_sub_field() after update_sub_field() – new data not returned

    When I update_sub_field() and then get_sub_field() the new data is not returned.
    Is there a way to force a new postmeta query?

    My pseudo code:

    1. Loop through sub fields of a Repeater field
    2. update_sub_field() when existing data is different.
    3. Loop through fields and get_sub_field() and display new data.

    I *could* keep a copy of the changed data and use that when displaying the new data but it would be easier to get fresh data from the database.

  • Solving

    the_field is not displaying

    example of code

                <?php
    
    $term = $_GET['s'];
    $expTerm = explode(" ",$term);
    
    $search = "(";
    foreach($expTerm as $ek=>$ev)
    {
    if($ek == 0)
    {
    $search .= "post_title LIKE '%".$ev."%'";
    }
    else
    {
    $search .= " OR post_title LIKE '%".$ev."%'";
    }
    }
    $search .= ")";
    
    $query = $wpdb->get_results(" SELECT * FROM ".$wpdb->prefix."posts WHERE post_status='publish' and $search ");
    ?>
                <?php
    
    foreach($query as $qk=>$qv)
    {
    $link = get_permalink($qv->ID);
    
    ?>
                <div class="col-12">
                    <div class="card stacked">
                        <div class="card-body">
                            <div class="row align-items-center">
                                <div class="col-md-2 text-center">
                                    <i
                                        class="icon-<?php the_field('category_icon', $qv->ID);?> icon-boxed icon-boxed-lg bg-blue text-white"></i>
                                </div>
                                <div class="col">
                                    <h3 class="card-title mt-2 mt-md-0 text-center text-md-left mb-2">
                                        <?php print $qv->post_title; ?>
                                    </h3>
                                    <div class="row">
                                        <div class="col-12">
                                            <p> <?php print wp_trim_words($qv->post_content,50,'...'); ?>
                                            </p>
                                        </div>
                                        <div class="mt-2 col-12">
                                            <a class="text-blue eyebrow action" href="<?php print $link;?>">Continue
                                                Reading</a>
                                        </div>
    
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
    
                <?php
    }
    ?>
  • Helping

    Displaying A button to Download a PDF (File)

    Hello there!

    I’ve been digging around for 2 days and I still didn’t solve this problem:

    As I’m creating an online catalog, I would like to dispay a button on each product page that’s linked to their unique PDF file (Datasheet) that I can define in backend with the File Field Type.

    Everything is going as planned, Here’s a look at the “setup”:

    ACF Setup

    but no matter how I pass the request, I always get a wrong HTML link like so:

    Here’s the code to retrieve the File Field Type

    <?php if( get_field('fiche_pdf') ): 
    $link= the_field('fiche_pdf');?>
              <a href="<?php echo $link;  ?>" target="_blank"><strong>Brochure</strong></a>
            <?php
            endif;?>

    Here’s the result

    http…/shop/product-name/<?php%20echo%20$link;%20%20?>

    I’ve tried with a Link field type, same result:

    Here’s the Code (as simple as possible):

    <a href="<?php echo esc_url($link); ?>">click here</a>

    And the result:

    http…/shop/product-name/<?php%20echo%20esc_url($link);%20?>

    I think that it’s related to the fact that I can’t execute php, because the code work if I use XYZ PHP CODE (Php shortcode plugin)

    Truly, the best goal for me is to be able to pass the url to an Advanced button (from WPBakery’s Mega Addons)

    But this is another problem…

    You can take a look at this here: http://mmpi.mrfortas.com/produit/compresseur-portatif-c-41/

    Thank you for your help πŸ™‚

  • Helping

    Find all articles that link to a specific book

    Hello!

    On my blog I have various post types, such as articles and books. With ACF I made a field ‘related_books’ to use with articles. In this field I can (optionally) link to multiple books.

    It is very easy to find all related books for an article.

    But what is the best way to do it the other way around?

    So when I am displaying a book, what is the most efficient way to find all articles that link to this book?

    Things I’ve tried:
    1) Querying for articles using wp_posts() and adding values for ‘meta_key’ and ‘meta_value’ –> I might have done it wrong but I got back all articles, even those that don’t mention any books at all.

    2) Taking it further one notch and using WP_Meta_Query. More work yet same effect as above

    3) Writing an SQL-statement that directly retrieves the right article-ID’s from the table ‘postmeta’. This works, but then I still need to fetch all article posts with these ID’s and it doesn’t really seem to be the most efficient and safe way to go

    4) Looping through all articles WP-style, and checking if the book on display is in their ACF field ‘related books’. Works. But also seems highly inefficient.

    What would be the best way to solve this? Best as in: efficient, safe and futureproof.

    This question doesn’t really seem unique, so if someone has already asked this (or solved this) I would be very happy with a reference too.

    Many thanks in advance πŸ™‚

Viewing 25 results - 101 through 125 (of 508 total)