Forum Replies Created

  • I also cant use an svg icon family like iconify. Which expects something like
    <span class=”iconify” data-icon=”mdi:account-arrow-left” data-inline=”false”></span>

    Which expands into an svg with javascript.

  • I figured the blocks were all saved statically to the post content.
    According to the handbook for Gutenberg extra work has to be done to make a dynamic block.

  • I just want to know if the fields made with acf can be dynamic like the Gutenberg native latest posts block.

  • Um…
    Why would there be no need?

    I’m making a site. The user can choose to add a block that shows the latest portfolio items on their site. They can choose how many to show and I can give other options.


  • Thanks for the info. I guess I’ll use that.

  • I got it working by looping through them all, getting the relationship field info and then just saving it right back via update_field…

    But there must be a way to easily get the hook update_value to run manually.
    I seem to only get it working when i press update post, but not when I use wp_update_post.

    I also tried wp_insert_post. Nope.

  • Thanks for the support John.

  • Thank you for responding.

    I contacted support with a ticket originally and they said it wasnt possible….

    So I concocted this crap.

    Now I see that they are wrong and it is possible.
    My issue was one of my layouts had a relationship field.
    I wanted to get the relationship ID’s.
    So I used
    get_sub_field('relationship_field', false)

    This does get the ID’s only but breaks the_row and stops the rest of sections outputting.

    I got the Id’s a different way (got the whole object and then used $object->ID)

    As for the file exists voodoo:

    get_template_part doesnt keep variables so if you make something like this:

    $var = 5;

    You cant use $var inside that template.
    So it’s kinda stupid.

    This allows you to get a template part without losing your variables, or needing to use global.
    It also uses locate_template which gets the right template if there is a child theme.
    Works nicely 🙂

  • So playing around I was able to sort of trick it… I check to see if any layouts are left even if have rows is now false.

    $id = get_the_ID();
    $sections = get_field( 'sections'); //get the section names
    $sections_count = count($sections); //count them
    if( have_rows('sections', $id) ):
    //check if have row OR THERE ARE STILL LAYOUTS LEFT
        while( have_rows('sections', $id) || $sections_count ): the_row();
        $section = get_row_layout();
    //lower amount of layouts left
    //each layout has its own file. very clean output. It's how I do.
    		if( file_exists( locate_template( 'template-parts/blocks/' . $section . '.php') )) {
    			include( locate_template( 'template-parts/blocks/' . $section . '.php' ) );
Viewing 9 posts - 1 through 9 (of 9 total)