WordPress.org

Ready to get started?Download WordPress

Forums

Adding three news blocks before a page's content (5 posts)

  1. David Borrink
    Member
    Posted 5 years ago #

    My client has asked for three blocks of editable information to be added at the top of a page, above a page's content. This page is a static front page with it's own template "front.php", so this is a one-time setup (all other pages will use the standard "page.php" template). This would be like adding those news blocks that appear at the bottom of the dashboard.

    I've dug around the codex and did searches here and with Google, but I'm not finding the information or similar situations to help me know if I'm thinking this procedure correctly.

    This is a big jump for me, so I'd like to know if...

    - I would add to the front.php template three new <?php include (TEMPLATEPATH . '/templatename.php'); ?> lines to call up three blocks.

    - Each of these new templates would contain the get-post information, <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>">but have the post id # in order to call up a specific page that contains the editable information. Then all my client would have to do is edit those "pages" to change the news items that appear on the front static page.

    - On style.css I would need to style each of the three templates with the positioning of the blocks (each template would have a separate class for positioning, but I would be able to have one combined class for typography)

    - I would need to be able to float the three news blocks in the content area above the static page's content, and to the right of the left sidebar which touches the header.

    I really could use a tip as to where floating three blocks in the content area could be done. Any good explanations out there for float and clear?

    I could use a little advice or at least be pointed to codex files which explain this, or perhaps a few others could let me know a better way to do this (i.e., would posts be better than pages to do the news items?)

  2. David Borrink
    Member
    Posted 5 years ago #

    Also, when adding multiple templates to a template with the

    <?php include (TEMPLATEPATH . '/templatename.php'); ?>

    instruction, is there a specific order these should be added, or will the css coding take care of the positioning?

    Thanks for any advice!

  3. David Borrink
    Member
    Posted 5 years ago #

    Any one?

  4. David Borrink
    Member
    Posted 5 years ago #

    Okay, this is a case where I was attempting something more complicated than it needed to be.

    I studied a couple other themes with news blocks and discovered.... tables! Okay. So trying to insert multiple templates together is way overkill.

    Well, that's a pretty basic method, so I wrote a three block table on the front.php template right above the content area, gave it it's own id and class, and will put a modified loop in each cell.

    Each loop will be to a post with a certain category parameter, and those three posts will only use their specified categories for themselves. That way if my client wants to add a blog later, those posts won't show up in the big loop.

  5. David Borrink
    Member
    Posted 5 years ago #

    It's working. I found an article that explained how to use a modified loop which calls up posts of a category (unique to that post) and quantity, placing them in the spot needed.

    The only drawback was that the content area of the page which had the regular loop, called up the last post from the blocks above. So I had to use the modified loop in that spot as well, and put the content in a post of it's own category, instead of a page entry.

    This might not be an issue if the three blocks were placed after the content area of a page, but I haven't tried that. That's theory.

    The news blocks expand in height at the moment, so I need to figure how to get them to stay fixed in height and use the "read more" feature to send readers to a post for more information.

Topic Closed

This topic has been closed to new replies.

About this Topic