Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Wordpress New Div

Featured Replies

Hi all,

 

My Wordpress theme looks like this.

 

The 'wrapper' class keeps all text and images (including the header) within 960px. I want to apply CSS to all content below the header and within 960px. No div currently exists that encloses this area (ie content div, sidebar div and footer div) so I think I need to create it. The area of this new div would like the yellow here.

 

So I think I need to add a div to index.php. I have tried a few things that don’t work. For example I enclosed the entire index.php except <?php get_header(); ?> in...

<div id=”new_div”>

...</div>

 

 

...but as you can see here (new_div in yellow) it doesn’t work (only a short bit enclosed and unhelpfully moves the sidebar).

 

Any suggestions please??

 

Thank you

 

 

 

index.php (including new_div added by me) =

 

<?php get_header(); ?>

<div id="new_div"> 

   <?php if (have_posts()) : ?>
   <?php while (have_posts()) : the_post(); ?>
   <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
       <div class="post-header">
           <div class="date"><?php the_time(__ ( 'M j', 'titan')); ?> <span><?php the_time( 'y' ); ?></span></div>
           <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
           <div class="author"><?php printf(__ ( 'by %s', 'titan'), get_the_author()); ?></div>
       </div><!--end post header-->
       <div class="entry clear">
           <?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail( array(250,9999), array( 'class' => ' alignleft border' )); ?>
           <?php the_content(__( 'read more...', 'titan')); ?>
           <?php edit_post_link(__( 'Edit', 'titan')); ?>
           <?php wp_link_pages(); ?>
       </div><!--end entry-->
       <div class="post-footer">
           <div class="comments"><?php comments_popup_link(__ ( 'Leave a comment', 'titan'), __ ( '1 Comment', 'titan'), __ngettext ( '% Comment', '% Comments', get_comments_number (),'titan')); ?></div>
       </div><!--end post footer-->
   </div><!--end post-->
   <?php endwhile; /* rewind or continue if all posts have been fetched */ ?>
   <div class="navigation index">
       <div class="alignleft"><?php next_posts_link(__ ( '« Older Entries', 'titan')); ?></div>
       <div class="alignright"><?php previous_posts_link(__ ( 'Newer Entries »', 'titan')); ?></div>
   </div><!--end navigation-->
   <?php else : ?>
   <?php endif; ?>
</div><!--end content-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

</div>

Add a new container (div wrapper) inside the current wrapper, float it left and use that instead.

 

You want the nested wrapper to float left and as you're using margin:auto; to centre the first wrapper you can't use a float with it.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.