• I made two categories, one for me and one for my friend so we can each post into our own column. Can someone help me out or point me at something I could look at to know how to write the code to make two divs with posts being assigned to a div based on their category? Thanks

    hippievstony.com

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter shatterjack

    (@shatterjack)

    thanks esmi,

    I read the article. I copied some code from there, could you tell me if I am going in the right direction? This seems to place all posts with the category “tony” in a list and then everything else goes into another list. Could I place the two lists side by side then? Thanks!

    <?php $my_query = new WP_Query(‘category_name=tony&showposts=3’);
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;?>
    <!– Do stuff… –>
    <?php endwhile; ?>
    <!– Do other stuff… –>
    <?php if (have_posts()) : while (have_posts()) : the_post();
    if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    <!– Do stuff… –>
    <?php endwhile; endif; ?>

    It looks about right. If you output List 1 into <div id="left"> and List 2 into <div id="right">, you could then use something like:

    #left,#right {
    width:50%;
    float:left;
    }

    in your CSS

    Thread Starter shatterjack

    (@shatterjack)

    would i place the div tag like this? I changed the second section to list posts with the “hippie” category rather than the leftovers after the call for “tony” posts. thanks esmi!

    <div id=”left”>
    <?php $my_query = new WP_Query(‘category_name=tony&showposts=3’);
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;?>
    <!– Do stuff… –>
    <?php endwhile; ?>
    </div>

    <div id=”right”>
    <?php $my_query = new WP_Query(‘category_name=hippie&showposts=3’);
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;?>
    <!– Do stuff… –>
    <?php endwhile; endif; ?>
    </div>

    Thread Starter shatterjack

    (@shatterjack)

    That looks about right.

    Thread Starter shatterjack

    (@shatterjack)

    Shoot I still need some help. I’m using the index.php from Kubrick. I keep getting this error:

    Parse error: syntax error, unexpected T_ELSE in /home1/hippievs/public_html/wp-content/themes/default/index.php on line 60

    Here is my main index:

    <?php
    /**
    * @package WordPress
    * @subpackage Default_Theme
    */

    get_header(); ?>

    <div id=”content” class=”narrowcolumn” role=”main”>

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    <div <?php post_class() ?> id=”post-<?php the_ID(); ?>”>
    <h2>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></h2>
    <small><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></small>

    <div class=”entry”>
    <?php the_content(‘Read the rest of this entry »’); ?>
    </div>

    <p class=”postmetadata”><?php the_tags(‘Tags: ‘, ‘, ‘, ‘
    ‘); ?> Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(‘No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?></p>
    </div>

    <?php endwhile; ?>

    <div class=”navigation”>
    <div class=”alignleft”><?php next_posts_link(‘« Older Entries’) ?></div>
    <div class=”alignright”><?php previous_posts_link(‘Newer Entries »’) ?></div>
    </div>

    /*inserted new stuff here
    */

    <div id=”left”>
    <?php $my_query = new WP_Query(‘category_name=tony&showposts=3’);
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;?>
    <?php endwhile; ?>
    </div>

    <div id=”right”>
    <?php $my_query = new WP_Query(‘category_name=hippie&showposts=3’);
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;?>
    <?php endwhile; endif; ?>
    </div>

    /*end of insertion*/

    <?php else : ?>

    <h2 class=”center”>Not Found</h2>
    <p class=”center”>Sorry, but you are looking for something that isn’t here.</p>
    <?php get_search_form(); ?>

    <?php endif; ?>

    </div>

    <?php get_sidebar(); ?>

    <?php get_footer(); ?>

    ———————
    ———————

    Any ideas? I’m not sure what’s going on. Also I put the

    #left,#right {
    width:50%;
    float:left;
    }

    in the structure portion of my style.css file. Does it matter where it goes in that list? Thanks a lot anyone!

    tony

    hippievstony.com

    Thread Starter shatterjack

    (@shatterjack)

    any ideas?

    Thread Starter shatterjack

    (@shatterjack)

    is the code I inserted screwing something up? Should I move it to a different place in the file? Is there a particular place in my css file to define this part:

    #left,#right {
    width:50%;
    float:left;
    }

    ?
    please help or point me to something…

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Create two divs in content area and assign each a category’ is closed to new replies.