Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
r171 return page title
#1
Hi! I wanted to tell you guys that
Code:
<?php return_page_title(); ?>
doesn't seem to work in r171.
Reply
#2
return_page_title() returns the page title. To display the title, you should:
Code:
<?php echo return_page_title(); ?>
or -simpler- use this other function:
Code:
<?php get_page_title(); ?>
More here: http://get-simple.info/docs/theme-codex
Reply
#3
Carlos Wrote:return_page_title() returns the page title. To display the title, you should:
Code:
<?php echo return_page_title(); ?>
or -simpler- use this other function:
Code:
<?php get_page_title(); ?>
More here: http://get-simple.info/docs/theme-codex

Sorry, my fault! I didn't know that. But I have to ask what is this useful for? I can find it useful for a plugin, but for a template?
Reply
#4
trilulilu17 Wrote:But I have to ask what is this useful for? I can find it useful for a plugin, but for a template?
Code:
if (trim(return_page_title())!='') { echo '<h1>'.return_page_title().'</h1>'; }
This will check whether a page title exists before trying to output it, this way you won’t be outputting an empty H1 element if no title is given. It also shows that return_page_title() is the one you’ll want to use within an echo statement.

Or maybe you want to use Shaun Inman’s Widon’t:
Code:
<h1><?php echo preg_replace('|([^\s])\s+([^\s]+)\s*$|', '$1&nbsp;$2', return_page_title()); ?></h1>

As long as these kind of things exist and will be created in the future you’ll want to be able to pass the title into your own PHP code within a template. At least that’s what we think and that’s why the return_ functions are included.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#5
Zegnåt Wrote:
trilulilu17 Wrote:But I have to ask what is this useful for? I can find it useful for a plugin, but for a template?
Code:
if (trim(return_page_title())!='') { echo '<h1>'.return_page_title().'</h1>'; }
This will check whether a page title exists before trying to output it, this way you won’t be outputting an empty H1 element if no title is given. It also shows that return_page_title() is the one you’ll want to use within an echo statement.

Or maybe you want to use Shaun Inman’s Widon’t:
Code:
<h1><?php echo preg_replace('|([^\s])\s+([^\s]+)\s*$|', '$1 $2', return_page_title()); ?></h1>

As long as these kind of things exist and will be created in the future you’ll want to be able to pass the title into your own PHP code within a template. At least that’s what we think and that’s why the return_ functions are included.

I see it now. Thank you!
Reply




Users browsing this thread: 1 Guest(s)