WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using this code to display a page within my front page. I would like to learn how to add a div / spacer to isolate the page title... If I try to add a div class within the php code then it throws errors.

Question: How can I add a div to the title within this bit of code?

<div class="frontpage">
$page_id = 2945; 
$page_data = get_page( $page_id ); 
echo '<h3>'. $page_data->post_title .'</h3>'; //enclose the title within a div/spacer???
echo apply_filters('the_content', $page_data->post_content);


share|improve this question
up vote 1 down vote accepted

Try to change heading from

echo '<h3>'. $page_data->post_title .'</h3>';


echo '<div class="class-name">'. $page_data->post_title .'</div>';
share|improve this answer
Thanks Sebastian - you must have posted that just as I was adding my answer - Thankyou :-) – speedypancake Nov 26 '12 at 9:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.