• Resolved tsg1846

    (@tsg1846)


    Environment

    Pods version: 3.3.9.2

    WordPress: 7.1

    PHP: 8.4

    Hosting environment: IONOS

    Description

    I am experiencing an issue with a Pods File / Image / Video field when using its Magic Tag inside an HTML href attribute.

    The file field itself works correctly and returns the expected full URL when output as normal text. The file is also publicly accessible and can be opened directly by non-authenticated visitors.

    However, when the same Magic Tag is used inside an <a href=""> attribute, Pods does not insert the file URL correctly. Instead, the field name itself ("antrag") is used as the link target.

    Pod configuration

    Custom Post Type Pod:

    aufnahmeantrag

    Fields:

    abteilung | Plain Text
    antrag | File / Image / Video

    Working example

    [pods name="aufnahmeantrag" limit="100" orderby="abteilung ASC"]
    <p><strong>Abteilung: {@abteilung}</strong></p>
    <p>File URL: {@antrag}</p>
    [/pods]

    This outputs the correct complete file URL, for example:

    https://example.com/wp-content/uploads/2026/09/application.pdf

    The URL is correct for both logged-in and logged-out users.

    Failing example

    [pods name="aufnahmeantrag" limit="100" orderby="abteilung ASC"]
    <p><strong>Abteilung: {@abteilung}</strong></p>
    <p>
    <a href="{@antrag}" target="_blank">
    Download application
    </a>
    </p>
    [/pods]

    The resulting link does not point to the file. Instead, the browser effectively receives:

    <a href="antrag" target="_blank">

    This results in navigation to a relative URL such as:

    https://example.com/antrag

    Important observation

    This is not an access-permission problem.

    The Magic Tag {@antrag} outputs the correct complete file URL.

    The complete file URL can be opened directly in an incognito/private browser window.

    The file therefore exists and is publicly accessible.

    The problem occurs specifically when {@antrag} is used inside the href attribute.

    Other Magic Tag syntax tested

    {@antrag._src}

    {@antrag.guid}

    {@antrag,esc_url}

    In this shortcode context these variants were not resolved as expected. They were either output literally or otherwise not interpreted as the file URL.

    PHP error

    There is also a related PHP fatal error reported by WordPress:

    Uncaught TypeError: strtolower(): Argument #1 ($string) must be of type string, array given

    Relevant part of the stack trace:

    #0 /wp-content/plugins/pods/classes/PodsUI.php(2682): strtolower()
    #1 /wp-content/plugins/pods/classes/PodsUI.php(2983): PodsUI->sort_data()
    #2 /wp-content/plugins/pods/classes/PodsUI.php(1448): PodsUI->manage()
    #3 /wp-content/plugins/pods/classes/PodsUI.php(590): PodsUI->go()
    #4 /wp-content/plugins/pods/includes/classes.php(118): PodsUI->__construct()
    #5 /wp-content/plugins/pods/classes/PodsAdmin.php(2024): pods_ui()
    #6 /wp-content/plugins/pods/classes/PodsAdmin.php(2024): PodsAdmin->admin_access_rights_review()

    The full error is:

    Uncaught TypeError: strtolower(): Argument #1 ($string) must be of type string, array given in
    /wp-content/plugins/pods/classes/PodsUI.php:2682

    Expected behavior

    I would expect {@antrag} to resolve to the same URL regardless of whether it is output as normal text or used as the value of an HTML href attribute.

    <a href="https://example.com/wp-content/uploads/2026/09/application.pdf">

    Actual behavior

    {@antrag}

    https://example.com/wp-content/uploads/2026/09/application.pdf

    <a href="{@antrag}">

    <a href="antrag">

    The Magic Tag therefore behaves differently depending on the output context.

    Possible underlying issue

    The File / Image / Video field appears to be represented internally as an array, while the normal Magic Tag output correctly resolves that value to a URL. It appears that the href attribute processing may be using the raw/internal field value instead of the resolved string URL.

    I am not certain whether the strtolower() error in PodsUI::sort_data() is directly related to the href/Magic Tag issue. I am reporting it as additional information because it also indicates that an array value may be reaching code that expects a string.

    Steps to reproduce

    Create a Pods Custom Post Type Pod named 'aufnahmeantrag'.

    Add a Plain Text field named 'abteilung'.

    Add a File / Image / Video field named 'antrag'.

    Upload/select a file for the 'antrag' field.

    Display the field using the Pods shortcode and {@antrag}.

    Confirm that the complete file URL is displayed.

    Use the same Magic Tag inside <a href="{@antrag}">.

    Open the page as a logged-out/incognito visitor and inspect/click the link.

    Observe that the link target is 'antrag' instead of the actual file URL.

    Request

    Could you please verify whether this is a bug/regression in Pods 3.3.9.2 related to File / Image / Video fields and Magic Tags used inside HTML attributes?

    In particular, please check whether the resolved file URL is being converted to a string before it is inserted into an href attribute, and whether the array handling in PodsUI::sort_data() is related to the same issue.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support pd

    (@pdclark)

    Isolating the working example and failing example to shortcode blocks within the WordPress core block editor produced two working examples within 3.3.9.2.

    The most likely cause of a situation in which a link containing a template <a href="{@antrag}"> is output as <a href="antrag"> is attempting to use the shortcode+template syntax within a page builder, page builder module, or similar custom layout context where output sanitation is being run before shortcodes are parsed.

    One possible solution is to move the template part of the shortcode:

    <p><strong>Abteilung: {@abteilung}</strong></p>
    <p>
    <a href="{@antrag}" target="_blank">
    Download application
    </a>
    </p>

    …to a named template under WP Admin > Pods Admin > Components > Pod Templates, for example a template named Bewerbungsvorlage containing the above.

    Then, change the shortcode to name the template rather than inline:

    [pods name="aufnahmeantrag" template="Bewerbungsvorlage" limit="100" orderby="abteilung ASC"]

    Note the name of the template is case-sensitive.

    That should work. If it does not, then one might consider the expected output compared to the actual output further, and whether the page layout editor, widget, or module in use is processing shortcodes or not.

    Thread Starter tsg1846

    (@tsg1846)

    Thank you very much for your help. It worked! 😊

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    We had a but where custom template input from a block/shortcode would go through wp_kses_post before the magic tags were evaluated. I have a fix that moves it correctly to be afterwards. Sorry about the inconvenience there.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.