The below code displays my selected page, its content and shortocde correctly. The page is selected from a theme options panel in the WP Admin.
I am struggling to echo the title. At the moment it’s echoing all page titles. Any help much apreciated!
<?php
$blockwho = get_option('good_blockwho');
$homeblockwho = get_pages ('post_name='.$blockwho); ?>
<?php foreach ($homeblockwho as $hbw) {
$content = $hbw->post_content;
$title = $hbw->post_title;
apply_filters('the_content', $content);
echo "<h2><span>".$title."</span></h2>";
echo "".do_shortcode($content)."";
}?>
Thanks again!
to echo the title of a singular wordpress page, you do this wordpress function
you can also surround it with some html for css formatting like follows->
good luck
according to the Codex : http://codex.wordpress.org/Function_Reference/get_pages
“post_name” is not an argument for get_pages, it’s a possible value for “sort_column”.
Try the following:
If you like to echo just the one page, this should do the trick:
Firstly I would recommend storing the actual page/post ID in the options table rather than the name of it, you can still display page titles to the user, just have a dropdown box with the option values as IDs
Have you checked $page->ID from j-man86’s answer is actually returning the correct ID?
Assuming the stored option is a page ID rather than a page title, the following would work