Hi,
My name is Dani and I am brand new here. I am just starting to learn PHP having somewhat mastered the basics of HTML and CSS over the last few years. I am getting to where I can read some PHP but can’t really write it yet.
I am trying to take this functionality which I have successfully gotten to work in the loop:
[php]
<?php
// array of category IDs
$categories = array(10,9,8,7,6,5,4,3,2,1);
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; ?>
</div>
[/php]
and use it in the http://wordpress.org/extend/plugins/recent-posts-slider/ so that I can achieve this:
slide 1= most recent post category 1
slide 2= most recent post category 2
etc
etc
etc
not
slide 1=post from june 22 in cat 2
slide 2=post from june 16 in cat 1
slide 3=post from june 13 in cat 3
etc
etc
The thing is I’m not sure exactly where to switch things out because I don’t know what all the php terms mean yet. I’m slowly weeding through what I know isn’t relative.
I am thinking this section has something to do with it:
[php]if ( empty($post_id) ) {
$args = array(
‘numberposts’ => $total_posts,
‘offset’ => 0,
‘category’ => $category_ids,
‘orderby’ => ‘post_date’,
‘order’ => ‘DESC’,
‘include’ => $post_include_ids,
‘exclude’ => $post_exclude_ids,
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’ );
$recent_posts = get_posts( $args );
if ( count($recent_posts)< $total_posts ) {
$total_posts = count($recent_posts);
}
foreach( $recent_posts as $key=>$val ) {
$post_details[$key]['post_ID'] = $val->ID;
$post_details[$key]['post_content'] = $val->post_content;
}
} else {
$post_details['0']['post_ID'] = $post_id;
$get_post_details = get_post( $post_id );
$post_details['0']['post_content'] = $get_post_details->post_content;
}
foreach ( $post_details as $key_p=> $val_p ) {
$first_img_name = '';
$img_name='';
$first_img_src = '';
$first_img_name_arr = get_post_custom_values('rps_custom_thumb', $val_p['post_ID']);
$first_img_name = $first_img_name_arr['0'];
if (function_exists('has_post_thumbnail') && has_post_thumbnail( $val_p['post_ID'] ) && empty($first_img_name)){
$img_details = wp_get_attachment_image_src( get_post_thumbnail_id( $val_p['post_ID'] ), 'full' );
$first_img_name = $img_details[0];
}else{
if(empty($first_img_name)){
preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $val_p['post_content'], $matches);
if ( count($matches) && isset($matches[1]) ) {
$first_img_name = $matches[1][0];
}
}[/php]
But if that is totally offbase I would be so so blessed if someone could quickly look through the file and let me know what they think. I think if someone knew how to read what I’m looking at they could get through it really fast.
Thank you so so much for your help!!
Dani