Support

Account

Forum Replies Created

  • Actually, it looks like the ACF block stores data in the the post content field as data. This is an example from a testimonial block entry.

    <!– wp:acf/testimonial-grid {
    “id”: “block_607ed8e56b83a”,
    “name”: “acf\/testimonial-grid”,
    “data”: {
    “testimonial_how_many”: “15”,
    “_testimonial_how_many”: “field_607d929e07f46”,
    “testimonial_how_many_cols”: “3”,
    “_testimonial_how_many_cols”: “field_607de7e495897”,
    “testimonial_include_image”: “0”,
    “_testimonial_include_image”: “field_607df0ae5e562”,
    “testimonial-background_color”: “#f7f7f7”,
    “_testimonial-background_color”: “field_60564f9d5d72a”,
    “testimonial-text_color”: “”,
    “_testimonial-text_color”: “field_60564fc05d72b”
    },
    “align”: “”,
    “mode”: “auto”
    } /–>

    So I want to grab some of this info and testimonial custom fields data in post meta values and render it on the front end of a block.

  • I need a way to pull the custom fields data saved in meta values as well as the block data saved in html comments- and then render that data in a grid loop.

  • A similar situation would be using a block to pull up a grid of latest posts. But instead of that, I want it to pull testimonials (custom post type with custom fields).

  • Yes- the block works but it doesn’t pull up the ACF fields from the database that were entered outside of the block. The block only pulls what was entered via the block fields and general WP fields like title and content. I want the ACF custom fields to be pulled. Thoughts?

  • Okay, when I make a page template, it works. So for some reason, it won’t pull the fields from the database via the block if they aren’t entered into the block. How can I have a block render custom fields that were previously entered in the database through ACF?

    Big picture, is I want the client to place the testimonials grid block on any page and set the number of testimonials and number of rows. Then I want the info to be pulled from the database to show it according to the block settings.

    Is this possible?

    Thanks.

  • Here is the full code on the page. I am not using namespace b/c that causes problems when I do, so I commented out the namespace.

    <?php
    /**
    * Testimonial block
    *
    * @package SWD\swd_realtor_theme
    * @subpackage Testimonial Block
    * @author Superfly Web Designs
    * @since 1.0.0
    * @license GPL-2.0+
    **/
    //namespace SWD\swd_realtor_theme;

    echo ‘<section id=”testimonial_grid” class=””>’;

    $testimonial_include_image = get_field(‘testimonial_include_image’);
    $testimonial_how_many = get_field(‘testimonial_how_many’);
    $testimonial_cols = get_field(‘testimonial_cols’);
    $testimonial_author = get_field(‘testimonial_author’);
    $testimonial_content = get_field(‘testimonial_content’);
    $testimonial_image = get_field(‘testimonial_image’);

    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’); ?></p>
    <?php endif; ?>

    </div>

    <?php endwhile;
    wp_reset_postdata();?>
    </div>
    </section>

  • Pls see the attachment of the Testimonial Entry fields.

    I have created a post-type Testimonial. The admin opens a “new” testimonial and enters the info in the ACF fields. This should save it in database.

    Then, I created a bock called Testmonial Grid where the admin can drop it in a page and select the number of testimonials to show and the number per row in the grid. The block redirects to the template testimonial.php in the blocks folder. The template should grab the data from the block and the data that was already entered in the database to render the testimonials on the template.

    The code I shared before won’t show any of the data the was entered in ACF fields. But it will show data that is part of a typical WordPress post like the Title. So, I am gathering the get_field() isn’t grabbing the meta-data that is should and I can’t figure out why.

    I have attached a screenshot of the fields. Thanks for your help.

Viewing 8 posts - 1 through 8 (of 8 total)