• Resolved PashkaRu

    (@pashkaru)


    problem with ACF plugin

    if I write echo do_shortcode("[insert page='300']"); , then all custom fields are displayed, if I additionally specify the template name, and write echo do_shortcode("[insert page='300' display='mytmpl.php']");, then custom fields are not displayed.

    What am I doing wrong?

    thanx!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Paul Ryan

    (@figureone)

    In your custom mytmpl.php, you need to use the ACF functions to render any ACF fields you want shown, such as the_field( 'my-acf-field' );.

    Hope that helps!

    Hello,

    I tried to do like you said above, but… it seems that there is some issue with id of the post that should be provided to the_field ACF function, let me explain my problem:

    – if I use: [insert page=’post-name’ display=’my-template.php’] where my template is using the ACF function the_field(‘name_of_field’), nothing happend.

    – if I use: [insert page=’post-name’ display=’all’] – I’ve got all fields that exists in my custom post type, so I assume that the post is available to read by Insert Pages plugin.

    – if I use: [insert page=’post-name’ display=’my-template.php’] where my template is using the ACF function the_field(‘name_of_field’,’id-of-the-post’), so I added the post id to the ACF function – it works fine.

    So, question is how to find and provide the post id to the ACF function in the template? Maybe it is simple ?? – I am not so familiar with coding in WordPress.

    I am working with WordPress 5.0.3, Insert Pages ver. 3.4.3, ACF ver. 5.7.10 and Custom Post Type UI ver. 1.6.1 (+ template Iconic One Pro v. 2.4).

    Best regards,
    Ziemowit

    Plugin Author Paul Ryan

    (@figureone)

    Sounds like your custom template is missing the Loop…the_post() is the core function that populates the global $post variable that all the template functions rely on (including ACF’s the_field()).
    https://developer.www.ads-software.com/reference/functions/the_post/

    My custom templates look like:

    <?php /* Template Name: Your Template Name */ ?>
    <?php while ( have_posts() ) : the_post(); ?>
      ... the rest of your template content goes here ...
    <?php endwhile; wp_reset_postdata(); ?>

    Hello,

    To tell the truth I did some workaround and used the function from your plugin, so my template does not use the Loop but only contains one line:

    <?php the_field(‘<Name of the field>’, $inserted_page->ID); ?>

    beside the first comments lines ??

    and it’s working :-).

    Is it workaround or proper set up?

    Best regards,
    Ziemowit.

    Plugin Author Paul Ryan

    (@figureone)

    Your solution looks fine!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Insert Pages width ACF’ is closed to new replies.