Call custom field in functions.php
-
In WP posts I have added a custom field named ‘googledriveurl’ in which a URL to Google Drive can be added. The WP installation is only on localhost at this stage and uses Polylang to handle two different languages (Swedish and English).
I have tried to create a shortcode in functions.php to return an a href link with the custom field included, along with some text in respective language and so far I have tried:
function googlesheetpdf_shortcode() { if (pll_current_language() == 'sv_SE') { echo '<a href="CUSTOMFIELD/view#gid=0">Spara som PDF</a>'; } else echo '<a href="CUSTOMFIELD/view#gid=146971">Save as PDF</a>'; } add_shortcode('googlesheetpdf', 'googlesheetpdf_shortcode');
I have searched around and tried a number of ways that I’ve come across but I’m stuck and confused – so I thought I’d ask and see if anyone could help.
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Call custom field in functions.php’ is closed to new replies.