2023-04-15, 17:14:10
(2016-11-05, 02:43:16)Carlos Wrote:(2016-11-01, 03:29:04)tibbz Wrote: I've used <?php getPageContent(return_page_slug(),'author'); ?> but all I get echoed is the username. How do I get the display name of the user please. It's there in the website.xml properties but not in the page properties.
Insert this in your theme's functions.php file (create it if it doesn't exist):
Code:if(!function_exists('get_page_author')) {
function get_page_author($echo=true) {
global $GSNAME, $data_index;
if (!$GSNAME) {
$author = (string)$data_index->author;
if (file_exists(GSUSERSPATH.$author.'.xml')) {
$userxml = getXML(GSUSERSPATH.$author.'.xml');
$GSNAME = !empty($userxml->NAME) ? htmlspecialchars($userxml->NAME) : $author;
} else {
$GSNAME = $author;
}
}
if ($echo)
echo $GSNAME;
else
return $GSNAME;
}
}
Then, you can display the page author name in your template with:
Code:<?php get_page_author(); ?>
Is it possible to use a condition with author name check for this function?