Article1_IOR |   id= 36958
[ featured id=’50955′ my_field=’featured’] [ featured id=’50955′ my_field=’featured’] ‹ fetches featured field in Article2
[ acf field=”featured” post_id=”50955″]

Goto Front page containing article excerpts

ACF-SCode insert from Article2 [ acf field=”acf_wys1″ post_id=”50955″][ acf field=”acf_wys2″ post_id=”50955″]

Article2 Excerpt: [ acf field=”acf_excerpt” post_id=”50955″] -› NotOK|Assigns the “hard content” contained in ACF fields from Article2, but pulls the Shortcode content acf_wys1/2 from Article1!!

[ xyz-ips snippet=”insert-acf-card0″ ] ?php the_field(‘acf_wys3’, 35406); ? Does not assign the remote data
[ insert page=’card0′ display=’excerpt-only’ ] Does not assign the remote data
< iframe src=”/posts/card0″ width=”100%” height=”400″ frameborder=”0″ allowfullscreen=”allowfullscreen” >< /iframe >

Content from the Post
|M|› ØfL1 style=width:28% · [ acf_im1 ] | Title · Lorem ‹|

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.

Content from the ACF_Excerpt field

Image field acf_wys1▷Classes: ØfL1.25% | Øsub3 (name=’acf_img1)


Use Advanced Custom Fields to insert Javascript into the page template

Advanced Custom Fields is a widely used plugin that allows you to implement custom fields without having to develop a ton of code.

With more than 1 million installations, Advanced Custom Fields is a proven, well-developed, and well-supported plugin.


Install and activate the plugin and you will have a new menu option in your Administrative menu called “Custom Fields.” Our goal with this example is to add a field that’s available only to administrators that will embed either a JavaScript source file or JavaScript code within the head or before the closing body tag.

1. Navigate to Custom Fields > Custom Fields and click Add New.

2. Name your Field Group. We named ours JavaScript Settings.

Advanced Custom Fields Plugin Usage for Adding JavaScript to WordPress

3. We enabled a rule to display the option only if the logged in user type was Administrator, ensuring that the fields could only be applied by an administrator of the site.

4. We’d like to display the fields in a section beneath the content area on the text editor, so we’re going to select Standard on the style of the Field Group.

JavaScript Settings in Post Entry

5. Now we need to add our Header Script and Footer Script custom fields and output them correctly. There are two key settings; the field name that will be referenced later in the template code and the formatting. You must set the formatting to the “Convert HTML into tags” option so that the contents that are pasted are properly executed in the template.

At this point, the fields will properly display within the Administration panel when an administrator is logged in. Any data entered will be saved and associated with the page or post once it’s saved or published. However, they will not display within the template until you edit your template files.

6. Within header.php in the active template, we will add:

<?php the_field(‘header_script'); ?>

before the </head> tag.

Header Script Code With WordPress Template

Within footer.php in the active template, we will add:

<?php the_field(‘footer_script'); ?>

before the </body> tag.

WordPress Template Source Code for Footer Script

7. Save the template files, update the page or post that you’ve specified JavaScript in, and click publish. The page or post will now be published with the JavaScript properly inserted into the template.

The Advanced Custom Fields option offers quite a bit of functionality. You may want to define your rules specific to certain users, published pages, or page templates rather than Administrators and all posts and pages. We’d highly recommend narrowing down access to adding scripts to only the pages, posts and users that they are required for.