Support

Account

Home Forums ACF PRO ACF field in an Object Tag.

Helping

ACF field in an Object Tag.

  • I am trying to use an ACF text field in a <object> tag, but it is not rendering.

    I am using a CodeBlock in WP to display a PDF inline on the page, but I can’t get the ACF tag to work inside an object tag. What I have is:

    === begin code block ===
    PDF File URL: [acf field="resource_file_url"]<br>
    <object
    data=”[acf field="resource_file_url"]”
    type=”application/pdf”
    width=”100%”
    height=”700″>
    </object>
    === end code block ===

    In the above example, the file URL is displayed on the page, but not inside the object tag (viewing the SRC, it is blank). Does anyone have a way to do this? I have tried different methods of displaying the ACF field too, and none of these work either inside the tag (while some do display the URL):

    [acf field="{$resource_file_url}"]
    [acf field='resource_file_url']
    [acf field={resource_file_url}]
    [acf field={$resource_file_url}]
    [acf field={"resource_file_url"}]
    [acf field=resource_file_url]
    [acf field="{$resource_file_url}"]

  • You cannot use shortcodes as an attribute of an element. This is a WP limitation/restriction.

    You will need to build your own shortcode that outputs all of the HTML to include ACF fields as attributes.

    Starting with version 4.2.3, similar limitations were placed on use of shortcodes inside HTML. For example, this shortcode will not work correctly because it is nested inside a scripting attribute:

    
    <a onclick="[tag]">
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.