2016-05-11, 17:21:34
(2013-08-30, 18:06:44)b3n.ji Wrote: Hey there,
maybe this was already asked before but: is there any way to get a custom field based on the page slug?
I need to duplicate a page, defining to get the content from page1 into page2, but the same does not work for the custom field I'm addionally calling.
Any suggestions? Or just mabye any way to get a second variable added to get_custom_field() ?
Thanks in advance!
You can use next code to achieve this:
PHP Code:
<?php getPageContent('page_slug', 'custom_field_name');
?>
Or use this as variable:
PHP Code:
<?php $variable = returnPageContent('page_slug', 'custom_field_name');
?>
If this index page, then 'page_slug' equal index
If you want to check if the your custom field have any content:
PHP Code:
<?php
$variable = returnPageContent('page_slug', 'custom_field_name');
if($variable) :
<h1>Header</h1>
echo $variable
endif ;
?>