• So I’ve created a custom template for a blog page on my site, and I made a new div #blogposts, as I want the blogposts in a different position from the content on the static home page.

    Here is the revelant HTML from the blog page template:
    <div id=”blogposts”>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2><?php the_title(); ?></h2>

    <div class=”entry”>
    <?php the_content(‘<p class=”serif”>’ . __(‘Read the rest of this page »’, ‘myelectrician’) . ‘</p>’); ?>

    <?php wp_link_pages(array(‘before’ => ‘<p>‘ . __(‘Pages:’, ‘myelectrician’) . ‘ ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>

    </div>

    When I make changes to .narrowcolumn the changes occur on the page, but when I make changes to #blogposts, nothing occurs. Here is the CSS:

    #blogposts {
    float: left;
    padding: 0 0 0 0px;
    margin-left: 50px;
    margin-top: 0px;
    width: 1200px;
    border: 1px solid;
    }

    .narrowcolumn {
    float: left;
    padding: 0 0 0px 0px;
    margin-left:75px;
    margin-top: 145px;
    width: 1200px;
    border: 1px solid;

    }

Viewing 15 replies - 1 through 15 (of 15 total)
  • can you post a link to a page using the template?

    what file name are you using for the template?

    what theme are you using?

    Thread Starter mishafart

    (@mishafart)

    I’m using the Kubrick theme however I’ve edited a lot of stuff.

    http://deathtonormalcy.site11.com/wordpress/wordpress/index.php/blog

    This is the page in question. Changes I make to .narrowcolumn take precedence to changes to #blogposts despite the fact that I have the #blogspots div wrapped around the actual blog part. It’s confusing. I just need a way to make a custom div take precedence over .narrowcolumn.

    When I look at your site, I don’t see <div id="blogposts"> on the page at all. Can you verify that you’re using the correct page template?

    Thread Starter mishafart

    (@mishafart)

    Yep, I’m using the correct page template setting on the actual page I just double checked. I have <div id=”blogposts”> in the file but even when I use the developer tools to search for blogposts div I can’t find it, there’s just .narrowcolumn.

    If the <div id=”blogposts”> doesn’t show up in the HTML source code it means that your site is not pulling up that file. You’ll need to edit the correct file for it to work.

    You may wish to review Template Hierarchy to be sure that the proper template is being used.

    Thread Starter mishafart

    (@mishafart)

    On the page editor part of the admin panel, I have my “blog” page with the template “blog” selected.

    On my blog template file in the theme, I have it starting with:

    <?php
    /*
    Template Name: blog
    */
    ?>

    I’m sure it’s something really simple. I just don’t know where I’m going wrong.

    The blog doesn’t use a page, that’s why it’s not working.
    Trying making your changes to index.php instead.

    Thread Starter mishafart

    (@mishafart)

    I’m sorry for all the confusions, the intricacies of wordpress themes really confuse me. I want a static home page so wouldn’t making changes to index.php mean having the blog on the home page?

    Not necessarily, because if you go to your Dashboard and then go to Settings > Reading, you can select a different static page to use as your site’s front page.

    Thread Starter mishafart

    (@mishafart)

    I’ve done that and my posts are set to appear on the “blog” page I created. I really don’t understand why the changes I make don’t appear on the page.

    Thread Starter mishafart

    (@mishafart)

    Ok, so when I made changes to the main index template “index.php”, the blog page changed. I don’t have that selected as the template to use for the blog page though, how can I have it so the blog template is the one that controls the changes?

    Short answer: you can’t. WordPress will always use the index.php template file for your main posts page – irrespective of any template you might try to apply.

    Thread Starter mishafart

    (@mishafart)

    Okay so would it work if I set the main posts page as an irrelevant page I don’t use, but then just use the code for the posts to show up on my blog pagE?

    Don’t bother applying any page template to your main posts page. Just leave the page template set to “Default”. If you need to make changes to the main posts template, you will need to edit the index.php template file – ideally via a child theme.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Unable to use custom div…’ is closed to new replies.