Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8208667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:27:16+00:00 2026-06-07T09:27:16+00:00

I have a page.php template and I want the first section to be wrapped

  • 0

I have a page.php template and I want the first section to be wrapped in <div id="featured"> to style it differently. How do I do it?

I can’t insert the div in my template since the_content() just outputs the whole content. I could insert the additional markup in the editor in HTML mode, but then I would have to repeat this process for every new page. Also the editor seems to insert empty p tags for no reason..

Markup looks like this:

<img>
<p>

<p>
<p>
<P>
...

What I want is:

<div id="featured">
 <img>
 <p>
</div>

<p>
<p>
...

What’s the best way to do this?

Edit: Thanks for your answers. After some more searching I found exactly what I was looking for, not as straightforward as I hoped but that’s life 🙂
http://wp.smashingmagazine.com/2011/10/14/advanced-layout-templates-in-wordpress-content-editor/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:27:19+00:00Added an answer on June 7, 2026 at 9:27 am

    A classic case for Featured images and excerpts!

    You would enable both in your functions.php

    add_post_type_support( 'page', 'excerpt' );
    add_theme_support( 'post-thumbnails');
    

    Then in your tempate files (page.php for pages and single.php for posts) you would have

     <div id="featured">
    
          // This is your excerpt
    
            <?php if(!empty($post->post_excerpt)) { ?>
    
                <div class="your-excerpt"><?php the_excerpt(); ?></div>
    
           <?php } ?>
    
         // And this is your featured image - pulled in at 960 wide
    
            <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {
    
                $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array( 960,960 )); ?>
    
                <div class="the-image">
                    <img src="<?php echo $img_src[0]; ?>" /> 
                </div>
    
        <?php }; ?>
    
      </div>
    

    To make sure the excerpts and featured images are visible in the backend, in your page and post edit screen hit the ‘Screen options’ tab on the top right hand corner and from the drop down make sure that the boxes are checked. Add your text into the excerpt input box and the upload your image through the featured image dialogue box on the right.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP page and I want to share some data between pages
Creating my WordPress author.php template page and ran into a little roadblock. I want
I have create separated page says service.php with following code <?php /* Template Name:
I have web page in PHP which displays all records in a table. I
I have a page index.php where i have a link called add_users.php. In add_users.php,
I have a page (main.php) which loads content from an external PHP file (rpc.php).
I have a php page and i have some javascript code to have a
I have a PHP page I need to limit execution access of to only
I have a PHP page that returns a piece of HTML to set the
I have a PHP page, in Wordpress. When I add a inline Thickbox to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.