Forums

Add 2 rows with content from 2 categories (16 posts)

  1. nyckidd
    Member
    Posted 1 year ago #

    Hello guys,

    I got a question, i would like to build a wordpress theme but i want 2 rows the top row would pull posts from category A and the second row would pull posts from category B

    All the articles would be in a horizontal layout ....how do i acheive this is there a plugin ? do i use widgets ? what code do i put on the index.php ?

    Any help!!

    Thanks

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

  3. nyckidd
    Member
    Posted 1 year ago #

    Thanks for the link i got it working but how do i style it so the articles are side by side ie

    right now the articles sitting on each other ie

    article A
    article B

    but i would like them to be like

    article A | article B

    any piointers ?

  4. MAS
    Member
    Posted 1 year ago #

    <div id="post">Article A</div>
    <div id="post">Article A</div>

    #post{
     display: inline;
     padding-right: 10px;
     width: 250px;
    }
  5. nyckidd
    Member
    Posted 1 year ago #

    thanks this is my code...i think my post is an id not a class....hope you can point me in the right direction...

    <div id="videos">
    
                <?php $my_query = new WP_Query('category_name=videos&posts_per_page=2');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID; ?>
    
    <div class="post <?php if ($counter == 1) { echo 'fl'; } else { echo 'fr'; $counter = 0; } ?>">
    
                <div class="box-post-content">
                <?php get_image('image',get_option('home_thumb_width'),get_option('home_thumb_height')); ?>
                <h2><a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    
                <p><?php echo strip_tags(get_the_excerpt(), '<a><strong>'); ?></p>
                </div>
                <p><span class="continue"><a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>">Read the full story</a></span></p>
    
            <p class="posted">Posted in <?php the_category(', ') ?><span class="comments"><?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?></span></p>
            </div><!--/post-->
    
              <?php endwhile; ?>
    
    </div>
              <div id="stats">
    
                <?php $my_query = new WP_Query('category_name=statistics&posts_per_page=2');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID; ?>
    
    <div class="post <?php if ($counter == 1) { echo 'fl'; } else { echo 'fr'; $counter = 0; } ?>">
    
                <div class="box-post-content">
                <?php get_image('image',get_option('home_thumb_width'),get_option('home_thumb_height')); ?>
                <h2><a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    
                <p><?php echo strip_tags(get_the_excerpt(), '<a><strong>'); ?></p>
                </div>
                <p><span class="continue"><a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>">Read the full story</a></span></p>
    
            <p class="posted">Posted in <?php the_category(', ') ?><span class="comments"><?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?></span></p>
            </div><!--/post-->
    
              <?php endwhile; ?>
    
    </div>
  6. nyckidd
    Member
    Posted 1 year ago #

    i think i got it....i just added your css to the id post

  7. MAS
    Member
    Posted 1 year ago #

    edit your style.css file and search .post css. U will change somethings like

    .post{
    display: inline:
    float: left;
    width: 250px;
    padding-right: 15px;
    }

  8. nyckidd
    Member
    Posted 1 year ago #

    worked like a charm...thanks chinmoy29 :)

  9. nyckidd
    Member
    Posted 1 year ago #

    oh yeah and thanks to Ms Theme Diva esmi :) for the introductory link :)

  10. nyckidd
    Member
    Posted 1 year ago #

    uh-oh!!

    everything is working like a charm.....quick question how do i randomize articles from a specific category on the homepage ?

  11. MAS
    Member
    Posted 1 year ago #

    use order=rand

  12. nyckidd
    Member
    Posted 1 year ago #

    where do i place that in my code ?

  13. MAS
    Member
    Posted 1 year ago #

    new WP_Query('category_name=videos&posts_per_page=2&order=rand');

    check the code....donate me!!!heheheehe lol

  14. nyckidd
    Member
    Posted 1 year ago #

    thanks dude / dudette i think you meant

    orderby=rand

    send me your email will use you for some more questions and of course a small donation :)

  15. MAS
    Member
    Posted 1 year ago #

    Coollllllllllllllll.....:) buddy u r so crazy man i like it. this is open forum and every body help the guys without donation. plz write here ur question and everybody feel free answer to you.

    chinmoy29.wordpress.com

  16. nyckidd
    Member
    Posted 1 year ago #

    thanks bro...nice theme...i got you

Topic Closed

This topic has been closed to new replies.

About this Topic