Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Name of Author
#24
(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?
Reply


Messages In This Thread
Name of Author - by D.O. - 2013-02-25, 21:44:09
RE: Name of Author - by eatons - 2013-02-26, 01:59:52
RE: Name of Author - by yojoe - 2013-02-28, 20:55:56
RE: Name of Author - by eatons - 2013-02-28, 22:07:10
RE: Name of Author - by datiswous - 2013-03-02, 01:57:48
RE: Name of Author - by D.O. - 2013-03-14, 20:52:14
RE: Name of Author - by shawn_a - 2013-03-14, 22:22:42
RE: Name of Author - by D.O. - 2013-03-15, 18:03:53
RE: Name of Author - by shawn_a - 2013-03-16, 01:44:08
RE: Name of Author - by D.O. - 2013-03-16, 02:22:45
RE: Name of Author - by D.O. - 2013-03-18, 20:21:04
RE: Name of Author - by eatons - 2013-03-18, 20:37:08
RE: Name of Author - by shawn_a - 2013-03-18, 23:20:36
RE: Name of Author - by D.O. - 2013-03-20, 02:06:22
RE: Name of Author - by datiswous - 2013-03-22, 01:13:18
RE: Name of Author - by shawn_a - 2013-03-22, 02:00:20
RE: Name of Author - by D.O. - 2013-07-23, 23:56:33
RE: Name of Author - by tibbz - 2016-11-01, 03:29:04
RE: Name of Author - by D.O. - 2016-11-01, 20:54:19
RE: Name of Author - by Carlos - 2016-11-05, 02:43:16
RE: Name of Author - by Oleg06 - 2023-04-15, 17:14:10
RE: Name of Author - by tibbz - 2016-11-05, 12:19:53
RE: Name of Author - by D.O. - 2016-11-09, 03:47:28
RE: Name of Author - by Carlos - 2016-11-05, 20:07:42



Users browsing this thread: 1 Guest(s)