Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Plugins & Atahualpa (http://forum.bytesforall.com/forumdisplay.php?f=16)
-   -   Most Recent Posts Slider: Pull From Each Category (http://forum.bytesforall.com/showthread.php?t=18361)

theadventurebite Sep 13, 2012 09:21 AM

Most Recent Posts Slider: Pull From Each Category
 
Okay so I finally figured out how to get the most recent post from multiple categories to pull properly.

This is the most basic of basic index.php to do this and pull it into the loop.

Code:

<?php
get_header();
?>
      <div id="content">
      <?php
  // array of category IDs
  $categories =  array(4, 5, 6);

  foreach ($categories as $cat) :
    $post = false;
    $post = get_posts('cat='.$cat.'&posts_per_page=1');
    if($post) :
      $post = $post[0];
      setup_postdata($post);
      get_template_part('content',get_post_format());
      ?>
    <?php endif; ?>
  <?php endforeach; ?>
      </div>
 
  <?php get_sidebar(); ?>
  <?php get_footer(); ?>

What I am trying to do is get the Most Recent Posts Slider to have this functionality.

I am so basic at php that I am struggling to know where to take this code and insert it.

I know it's not a ton but I would be willing to donate $10 to anyone who can help me get this put where it needs to go.

Thanks!

Dani

theadventurebite Sep 13, 2012 09:28 AM

I do not need it to function in the output fields in the Setting areas or have that aspect cleaned up after removing other variables, etc. I just need it to function properly, I can handle editing categories that are pulled etc, if I ever need to change them in the code itself.

Thanks


All times are GMT -6. The time now is 11:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.