{"id":19012238,"date":"2026-09-05T08:41:28","date_gmt":"2026-09-05T08:41:28","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/file-field-magic-tag-resolves-incorrectly-inside-an-href-attribute\/"},"modified":"2026-09-05T08:41:28","modified_gmt":"2026-09-05T08:41:28","slug":"file-field-magic-tag-resolves-incorrectly-inside-an-href-attribute","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/file-field-magic-tag-resolves-incorrectly-inside-an-href-attribute\/","title":{"rendered":"File field Magic Tag resolves incorrectly inside an href attribute"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code><strong>Environment<\/strong><br \/><br \/>Pods version: 3.3.9.2<br \/><br \/>WordPress: 7.1<br \/><br \/>PHP: 8.4<br \/><br \/>Hosting environment: IONOS<br \/><br \/><strong>Description<\/strong><br \/><br \/>I am experiencing an issue with a Pods File \/ Image \/ Video field when using its Magic Tag inside an HTML href attribute.<br \/><br \/>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.<br \/><br \/>However, when the same Magic Tag is used inside an &lt;a href=\"\"&gt; attribute, Pods does not insert the file URL correctly. Instead, the field name itself (\"antrag\") is used as the link target.<br \/><br \/><strong>Pod configuration<\/strong><br \/><br \/>Custom Post Type Pod:<br \/><br \/>aufnahmeantrag<br \/><br \/>Fields:<br \/><br \/>abteilung | Plain Text<br \/>antrag | File \/ Image \/ Video<br \/><br \/><strong>Working example<\/strong><br \/><br \/>&#091;pods name=\"aufnahmeantrag\" limit=\"100\" orderby=\"abteilung ASC\"]<br \/>    &lt;p&gt;&lt;strong&gt;Abteilung: {@abteilung}&lt;\/strong&gt;&lt;\/p&gt;<br \/>    &lt;p&gt;File URL: {@antrag}&lt;\/p&gt;<br \/>&#091;\/pods]<br \/><br \/>This outputs the correct complete file URL, for example:<br \/><br \/>https:\/\/example.com\/wp-content\/uploads\/2026\/09\/application.pdf<br \/><br \/>The URL is correct for both logged-in and logged-out users.<br \/><br \/><strong>Failing example<\/strong><br \/><br \/>&#091;pods name=\"aufnahmeantrag\" limit=\"100\" orderby=\"abteilung ASC\"]<br \/>    &lt;p&gt;&lt;strong&gt;Abteilung: {@abteilung}&lt;\/strong&gt;&lt;\/p&gt;<br \/>    &lt;p&gt;<br \/>        &lt;a href=\"{@antrag}\" target=\"_blank\"&gt;<br \/>            Download application<br \/>        &lt;\/a&gt;<br \/>    &lt;\/p&gt;<br \/>&#091;\/pods]<br \/><br \/>The resulting link does not point to the file. Instead, the browser effectively receives:<br \/><br \/>&lt;a href=\"antrag\" target=\"_blank\"&gt;<br \/><br \/>This results in navigation to a relative URL such as:<br \/><br \/>https:\/\/example.com\/antrag<br \/><br \/><strong>Important observation<\/strong><br \/><br \/>This is not an access-permission problem.<br \/><br \/>The Magic Tag {@antrag} outputs the correct complete file URL.<br \/><br \/>The complete file URL can be opened directly in an incognito\/private browser window.<br \/><br \/>The file therefore exists and is publicly accessible.<br \/><br \/>The problem occurs specifically when {@antrag} is used inside the href attribute.<br \/><br \/><strong>Other Magic Tag syntax tested<\/strong><br \/><br \/>{@antrag._src}<br \/><br \/>{@antrag.guid}<br \/><br \/>{@antrag,esc_url}<br \/><br \/>In this shortcode context these variants were not resolved as expected. They were either output literally or otherwise not interpreted as the file URL.<br \/><br \/><strong>PHP error<\/strong><br \/><br \/>There is also a related PHP fatal error reported by WordPress:<br \/><br \/>Uncaught TypeError: strtolower(): Argument #1 ($string) must be of type string, array given<br \/><br \/>Relevant part of the stack trace:<br \/><br \/>#0 \/wp-content\/plugins\/pods\/classes\/PodsUI.php(2682): strtolower()<br \/>#1 \/wp-content\/plugins\/pods\/classes\/PodsUI.php(2983): PodsUI-&gt;sort_data()<br \/>#2 \/wp-content\/plugins\/pods\/classes\/PodsUI.php(1448): PodsUI-&gt;manage()<br \/>#3 \/wp-content\/plugins\/pods\/classes\/PodsUI.php(590): PodsUI-&gt;go()<br \/>#4 \/wp-content\/plugins\/pods\/includes\/classes.php(118): PodsUI-&gt;__construct()<br \/>#5 \/wp-content\/plugins\/pods\/classes\/PodsAdmin.php(2024): pods_ui()<br \/>#6 \/wp-content\/plugins\/pods\/classes\/PodsAdmin.php(2024): PodsAdmin-&gt;admin_access_rights_review()<br \/><br \/>The full error is:<br \/><br \/>Uncaught TypeError: strtolower(): Argument #1 ($string) must be of type string, array given in<br \/>\/wp-content\/plugins\/pods\/classes\/PodsUI.php:2682<br \/><br \/><strong>Expected behavior<\/strong><br \/><br \/>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.<br \/><br \/>&lt;a href=\"https:\/\/example.com\/wp-content\/uploads\/2026\/09\/application.pdf\"&gt;<br \/><br \/><strong>Actual behavior<\/strong><br \/><br \/>{@antrag}<br \/>\u2193<br \/>https:\/\/example.com\/wp-content\/uploads\/2026\/09\/application.pdf<br \/><br \/>&lt;a href=\"{@antrag}\"&gt;<br \/>\u2193<br \/>&lt;a href=\"antrag\"&gt;<br \/><br \/>The Magic Tag therefore behaves differently depending on the output context.<br \/><br \/><strong>Possible underlying issue<\/strong><br \/><br \/>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.<br \/><br \/>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.<br \/><br \/><strong>Steps to reproduce<\/strong><br \/><br \/>Create a Pods Custom Post Type Pod named 'aufnahmeantrag'.<br \/><br \/>Add a Plain Text field named 'abteilung'.<br \/><br \/>Add a File \/ Image \/ Video field named 'antrag'.<br \/><br \/>Upload\/select a file for the 'antrag' field.<br \/><br \/>Display the field using the Pods shortcode and {@antrag}.<br \/><br \/>Confirm that the complete file URL is displayed.<br \/><br \/>Use the same Magic Tag inside &lt;a href=\"{@antrag}\"&gt;.<br \/><br \/>Open the page as a logged-out\/incognito visitor and inspect\/click the link.<br \/><br \/>Observe that the link target is 'antrag' instead of the actual file URL.<br \/><br \/><strong>Request<\/strong><br \/><br \/>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?<br \/><br \/>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.<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-19012238","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19012238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19012238\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19012238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}