• Resolved crisp82

    (@crisp82)


    Hi,

    I have installed TheMorningAfter from WooThemes, and am working on customising the main page. I would like to have the main page show the 10 most recent posts, with 5 featured posts in the sidebar. As this is one of their free themes, there is no support, and the forums are via paid subscription only.

    I am very new to PHP however and cannot quite get to grips with the code on the page.

    The current code that displays the latest post, and then a featured posts below:

    <?php
    				while (have_posts()) : the_post();
    
    				$do_not_duplicate = $post->ID; ?>
    
    				<div id="latest_post">
    					<h3 class="mast"><?php _e('Latest Posts','woothemes'); ?></h3>
    
    					<div id="latest_post_image">
    					<?php woo_image('width=470&height=210'); ?>
    					</div>
    
    					<h3 class="latest_post_title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    
    					<p><?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else the_excerpt(); ?></p>
    
    					<div class="latest_post_meta">
    						<span class="latest_read_on"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php _e('Continue Reading','woothemes'); ?></a></span>
    						<span class="latest_comments"><?php comments_popup_link('Post a comment', 'One comment', '% comments', '', 'Comments off'); ?></span>
    						<?php $cat = get_the_category(); $cat = $cat[0]; ?>
    						<span class="latest_category"><a href="<?php echo get_category_link($cat->cat_ID);?>"><?php echo $cat->cat_name; ?></a></span>
    					</div>
    				</div>
    
    				<?php
    				break;
    				endwhile; ?>
    
    				<div id="home_featured">
    					<h3 class="home_featured"><?php echo $woo_options['woo_featured_heading']; ?></h3>
    
    					<?php
    					$feat_id = get_cat_id($woo_options['woo_featured_category']);
    					$limit = $woo_options['woo_featured_limit'];
    					$the_query = new WP_Query("cat=$feat_id&showposts=$limit");
    
    					while ($the_query->have_posts()) : $the_query->the_post();
    
    					$do_not_duplicate = $post->ID; ?>
    
    					<div class="feat_content">
    
    						<?php woo_image("width=65&height=65"); ?>
    
    						<div class="feat_title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>"><?php the_title(); ?></a></div>
    
    						<div class="feat_exc">
    							<?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else the_excerpt(); ?>
    						</div>
    
    					</div>
    
    					<?php endwhile; ?>
    
    				</div>

    Is there anyway to adapt the code to show the 10 most recent posts?

    Thanks,

    crisp82

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter crisp82

    (@crisp82)

    *Bump

    <?php
            query_posts($query_string . "&showposts=10");
    				while (have_posts()) : the_post();
    
    				$do_not_duplicate = $post->ID; ?>
    
    				<div id="latest_post">
    					<h3 class="mast"><?php _e('Latest Posts','woothemes'); ?></h3>
    
    					<div id="latest_post_image">
    					<?php woo_image('width=470&height=210'); ?>
    					</div>
    
    					<h3 class="latest_post_title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    
    					<p><?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else the_excerpt(); ?></p>
    
    					<div class="latest_post_meta">
    						<span class="latest_read_on"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php _e('Continue Reading','woothemes'); ?></a></span>
    						<span class="latest_comments"><?php comments_popup_link('Post a comment', 'One comment', '% comments', '', 'Comments off'); ?></span>
    						<?php $cat = get_the_category(); $cat = $cat[0]; ?>
    						<span class="latest_category"><a href="<?php echo get_category_link($cat->cat_ID);?>"><?php echo $cat->cat_name; ?></a></span>
    					</div>
    				</div>
    
    				<?php
    				break;
    				endwhile; ?>
    
    				<div id="home_featured">
    					<h3 class="home_featured"><?php echo $woo_options['woo_featured_heading']; ?></h3>
    
    					<?php
    					$feat_id = get_cat_id($woo_options['woo_featured_category']);
    					$limit = $woo_options['woo_featured_limit'];
    					$the_query = new WP_Query("cat=$feat_id&showposts=$limit");
    
    					while ($the_query->have_posts()) : $the_query->the_post();
    
    					$do_not_duplicate = $post->ID; ?>
    
    					<div class="feat_content">
    
    						<?php woo_image("width=65&height=65"); ?>
    
    						<div class="feat_title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>"><?php the_title(); ?></a></div>
    
    						<div class="feat_exc">
    							<?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else the_excerpt(); ?>
    						</div>
    
    					</div>
    
    					<?php endwhile; ?>
    
    				</div>
    Thread Starter crisp82

    (@crisp82)

    Thanks!

    I receive the following error when loading this though:

    Parse error: syntax error, unexpected T_ENDWHILE in /home/crisp82/public_html/wp-content/themes/themorningafter/home.php on line 43

    The website is

    Thread Starter crisp82

    (@crisp82)

    Here

    Not sure why that didn’t work before!

    is it working now? I just add this line at the top

    query_posts($query_string . "&showposts=10");

    Thread Starter crisp82

    (@crisp82)

    I think I may be inserting the code incorrectly. When added, it displays as it was before.

    Previously, it was this:

    <?php get_header(); ?>
    <?php global $woo_options; ?>
    		<div id="topbanner" class="column span-14" style="background-image:url(<?php header_image(); ?>)">
                <div class="pagetitle">
                    <?php echo $woo_options['woo_pageheading_prefix'] . $woo_options['woo_pageheading_home']; ?>
                </div>
            </div> 
    
            <div id="home_content" class="column span-14">
    
                <div id="home_left" class="column span-10 first">
    
    		<?php if (function_exists(s3slider_show())) { s3slider_show(); } ?>
    
    				<?php
    				while (have_posts()) : the_post();
    
    				$do_not_duplicate = $post->ID; ?>
    
    				<div id="latest_post">
    					<h3 class="mast"><?php _e('Latest Posts','woothemes'); ?></h3
    
    					<div id="latest_post_image">
    					<?php woo_image('width=470&height=210'); ?>
    					</div>
    
    					<h3 class="latest_post_title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    
    <small>Posted on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?></small>
    
    					<p><?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else the_excerpt(); ?></p>
    
    <small>Filed under <?php the_category(', ') ?>.</small<p></p>				
    
    					<div class="latest_post_meta">
    						<span class="latest_read_on"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php _e('Continue Reading','woothemes'); ?></a></span>
    						<span class="latest_comments"><?php comments_popup_link('Post a comment', 'One comment', '% comments', '', 'Comments off'); ?></span>
    						<?php $cat = get_the_category(); $cat = $cat[0]; ?>
    						<span class="latest_category"><a href="<?php echo get_category_link($cat->cat_ID);?>"><?php echo $cat->cat_name; ?></a></span>
    					</div>
    				</div>
    
    				<?php
    				break;
    				endwhile; ?>
    
    				<div id="home_featured">
    					<h3 class="home_featured"><?php echo $woo_options['woo_featured_heading']; ?></h3>
    
    					<?php
    					$feat_id = get_cat_id($woo_options['woo_featured_category']);
    					$limit = $woo_options['woo_featured_limit'];
    					$the_query = new WP_Query("cat=$feat_id&showposts=$limit");
    
    					while ($the_query->have_posts()) : $the_query->the_post();
    
    					$do_not_duplicate = $post->ID; ?>
    
    					<div class="feat_content">
    
    						<?php woo_image("width=65&height=65"); ?>
    
    						<div class="feat_title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>"><?php the_title(); ?></a></div>
    
    						<div class="feat_exc">
    							<?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else the_excerpt(); ?>
    						</div>
    
    					</div>
    
    					<?php endwhile; ?>
    
    				</div>
    
    				<div id="home_asides">
    
    					<h3 class="mast"><?php echo $woo_options['woo_updates_heading']; ?></h3>
    
    					<ul class="arrow">
    						<?php
    						$limit = $woo_options['woo_updates_limit'];
    						$the_query = new WP_Query("post_type=updates&showposts=$limit");
    
    						while ($the_query->have_posts()) : $the_query->the_post();
    
    						$do_not_duplicate = $post->ID; ?>
    
    						<li><?php echo strip_tags(get_the_content(), '<a>'); ?> <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>">#</a></li>
    
    						<?php endwhile; ?>
    					</ul>
    				</div>
                </div>            
    
                <div id="home_right" class="column span-4 last">
                	<?php if(!empty($woo_options['woo_home_heading']) && !empty($woo_options['woo_home_text'])){ ?>
                	<div id="home_about">
    
    					<?php if (!empty($woo_options['woo_home_heading'])) { ?><h3 class="mast3"><?php echo $woo_options['woo_home_heading']; ?></h3><?php } ?>
    					<?php if (!empty($woo_options['woo_home_text'])) { ?><p><?php echo $woo_options['woo_home_text']; ?><p><?php } ?>		
    
    				</div>
    				<?php } ?>
    
    				<div class="column span-4 first">
    
    					<?php if ( !function_exists('dynamic_sidebar')
    					        || !dynamic_sidebar('middle_sidebar') ) : ?>
    
    					<?php endif; ?>
    
                	</div>
    
                    <?php get_sidebar(); ?>         
    
                </div>
    
            </div>    
    
    <?php get_footer(); ?>

    and now:

    <?php get_header(); ?>
    <?php global $woo_options; ?>
    		<div id="topbanner" class="column span-14" style="background-image:url(<?php header_image(); ?>)">
                <div class="pagetitle">
                    <?php echo $woo_options['woo_pageheading_prefix'] . $woo_options['woo_pageheading_home']; ?>
                </div>
            </div> 
    
            <div id="home_content" class="column span-14">
    
                <div id="home_left" class="column span-10 first">
    
    		<?php if (function_exists(s3slider_show())) { s3slider_show(); } ?>
    
    				<?php
            query_posts($query_string . "&showposts=10");
    				while (have_posts()) : the_post();
    
    				$do_not_duplicate = $post->ID; ?>
    
    				<div id="latest_post">
    					<h3 class="mast"><?php _e('Latest Posts','woothemes'); ?></h3>
    
    					<div id="latest_post_image">
    					<?php woo_image('width=470&height=210'); ?>
    					</div>
    
    					<h3 class="latest_post_title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    
    					<p><?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else the_excerpt(); ?></p>
    
    					<div class="latest_post_meta">
    						<span class="latest_read_on"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php _e('Continue Reading','woothemes'); ?></a></span>
    						<span class="latest_comments"><?php comments_popup_link('Post a comment', 'One comment', '% comments', '', 'Comments off'); ?></span>
    						<?php $cat = get_the_category(); $cat = $cat[0]; ?>
    						<span class="latest_category"><a href="<?php echo get_category_link($cat->cat_ID);?>"><?php echo $cat->cat_name; ?></a></span>
    					</div>
    				</div>
    
    				<?php
    				break;
    				endwhile; ?>
    
    				<div id="home_featured">
    					<h3 class="home_featured"><?php echo $woo_options['woo_featured_heading']; ?></h3>
    
    					<?php
    					$feat_id = get_cat_id($woo_options['woo_featured_category']);
    					$limit = $woo_options['woo_featured_limit'];
    					$the_query = new WP_Query("cat=$feat_id&showposts=$limit");
    
    					while ($the_query->have_posts()) : $the_query->the_post();
    
    					$do_not_duplicate = $post->ID; ?>
    
    					<div class="feat_content">
    
    						<?php woo_image("width=65&height=65"); ?>
    
    						<div class="feat_title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>"><?php the_title(); ?></a></div>
    
    						<div class="feat_exc">
    							<?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else the_excerpt(); ?>
    						</div>
    
    					</div>
    
    					<?php endwhile; ?>
    
    				</div>    
    
    <?php get_footer(); ?>
    <?php get_header(); ?>
    <?php global $woo_options; ?>
    		<div id="topbanner" class="column span-14" style="background-image:url(<?php header_image(); ?>)">
                <div class="pagetitle">
                    <?php echo $woo_options['woo_pageheading_prefix'] . $woo_options['woo_pageheading_home']; ?>
                </div>
            </div> 
    
            <div id="home_content" class="column span-14">
    
                <div id="home_left" class="column span-10 first">
    
    		<?php if (function_exists(s3slider_show())) { s3slider_show(); } ?>
    
    				<?php
            global $query_string;
    query_posts($query_string . "&showposts=10");
    				while (have_posts()) : the_post();
    
    				$do_not_duplicate = $post->ID; ?>
    
    				<div id="latest_post">
    					<h3 class="mast"><?php _e('Latest Posts','woothemes'); ?></h3>
    
    					<div id="latest_post_image">
    					<?php woo_image('width=470&height=210'); ?>
    					</div>
    
    					<h3 class="latest_post_title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    
    					<p><?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else the_excerpt(); ?></p>
    
    					<div class="latest_post_meta">
    						<span class="latest_read_on"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php _e('Continue Reading','woothemes'); ?></a></span>
    						<span class="latest_comments"><?php comments_popup_link('Post a comment', 'One comment', '% comments', '', 'Comments off'); ?></span>
    						<?php $cat = get_the_category(); $cat = $cat[0]; ?>
    						<span class="latest_category"><a href="<?php echo get_category_link($cat->cat_ID);?>"><?php echo $cat->cat_name; ?></a></span>
    					</div>
    				</div>
    
    				<?php
    				break;
    				endwhile; ?>
    
    				<div id="home_featured">
    					<h3 class="home_featured"><?php echo $woo_options['woo_featured_heading']; ?></h3>
    
    					<?php
    					$feat_id = get_cat_id($woo_options['woo_featured_category']);
    					$limit = $woo_options['woo_featured_limit'];
    					$the_query = new WP_Query("cat=$feat_id&showposts=$limit");
    
    					while ($the_query->have_posts()) : $the_query->the_post();
    
    					$do_not_duplicate = $post->ID; ?>
    
    					<div class="feat_content">
    
    						<?php woo_image("width=65&height=65"); ?>
    
    						<div class="feat_title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to','wootheme');?> <?php the_title(); ?>"><?php the_title(); ?></a></div>
    
    						<div class="feat_exc">
    							<?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else the_excerpt(); ?>
    						</div>
    
    					</div>
    
    					<?php endwhile; ?>
    
    				</div>    
    
    <?php get_footer(); ?>

    Now modify with it.

    Thread Starter crisp82

    (@crisp82)

    This doesn’t seem to change the layout. I can see 1 labelled ‘Latest Post’ and then it moves onto the ‘Featured Posts’ section. It seems to be ignoring:

    query_posts($query_string . "&showposts=10");

    ?

    $feat_id = get_cat_id($woo_options['woo_featured_category']);
    query_posts("cat=-{$feat_id}&showposts=10");

    read this

    Thread Starter crisp82

    (@crisp82)

    From what I can see, that is calling posts categorised as ‘Featured’, and listing 10. I am not sure where I can grab the latest 10 from though.

    I tried:

    $latest_id = get_cat_id($woo_options[‘woo_latest_category’]);
    query_posts(“cat=-{$latest_id}&showposts=10”);
    $the_query = new WP_Query(“cat=$feat_id&showposts=$limit”);

    This is not working either.

    I am not sure where the categories are defined. Is there a better way of calling the last 10 posts?

    Thanks

    crisp82

    $latest_id = get_cat_id($woo_options['woo_latest_category']);
    query_posts("cat={$latest_id}&showposts=10");
    Thread Starter crisp82

    (@crisp82)

    chinmoy,

    Thanks for the help! Sorry if I am missing something, but I cannot get this to work. I am adding this into the ‘home.php’, just above the <div=class> tag, in the same place as it is for the featured posts. This results in just outputting the code to the screen, while placing it any higher in the page nothing happens.

    Is this a result of the custom post types used in this theme?

    crisp82

    Thread Starter crisp82

    (@crisp82)

    I have found the followed code which is retuning the posts as I wanted:

    $loop = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => 10 ) );
    while ( $loop->have_posts() ) : $loop->the_post();
      the_title();
      echo '<div class="entry-content">';
      the_content();
      echo '</div>';
    endwhile;

    but the formatting is not being applied as per the ‘Latest Post’ section, just below. I have to paste this code before the <div id="latest_post"> but as such, it is not picking up the formatting. Where do I need to p[lace it to pick up the formatting, but still display the posts?

    Sorry for the n00b questions.

    crisp82

    Thread Starter crisp82

    (@crisp82)

    *bump. This is proving difficult to figure out. I think it has to do with the $woo_options that I keep seeing pop up in the files.

    Can one else assist?

    Thread Starter crisp82

    (@crisp82)

    Can someone please help with this? I am really stuck!

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘TheMorningAfter – Changing post type on main page’ is closed to new replies.