First of all, this is not an issue that prevents my website from working. This is a "hmm - this worked, but why?" issue. My website is http://www.stbedesantafe.org.
I created a "homepage.php" because I made 2 major alterations to the "index.php". (1) I wanted to display featured posts (created category "Feature" to accomplish this) on the front page, which now show in the middle column. (2) I created a static left sidebar to display a weekly schedule (built in a table).
I accomplished (2) quite by accident. I copied the sidebar code from the index.php, fully intending to try to figure out how to change it from calling the Page Right Sidebar to calling the Blog Right Sidebar. I pasted the code, changed the ( 'pageright' ) to ( 'pageleft' ), and then viewed my front page. I fully expected to see the Page Right Sidebar duplicated on the left and the right. It wasn't - the sidebar on the left was blank. For some reason, I thought to add some widgets to the Blog Right Sidebar, and they appeared on the left side of my page. That's the "that worked, but why?" part of my question. I thought I would have to change "get_sidebar" to "get_something_else", but I didn't. The code automatically called the Blog Right Sidebar. Can you explain that, and do I really need to have "get_something_else" in my code? (Sometimes I am of the ain't broke don't fix school, but this seems as if it could be unstable.)
For change (1), I found some code based on someone else's solution to displaying a specific category of posts on an otherwise static front page, and the code does exactly what I wanted it to. I have placed the code so that the posts appear in the middle column, but there is a lot of real estate between the page title ("Welcome ....") and the first post. Is there a way you can see to eliminate all that blank space?
Here is the entire code for the homepage.php:
<?php /* Template Name: Homepage */ ?> <?php // Exit if accessed directly if ( !defined('ABSPATH')) exit; /** * Main Template * * @file index.php * @package Preference Lite * @author Andre Jutras * @copyright 2013 StyledThemes.com * @license license.txt * @version Release: 1.0 * @since available since Release 1.0 */ get_header(); ?> <!-- Main Content --> <div class="container"> <div class="row"> <!-- Component --> <aside id="right-column" class="span3"> <?php get_sidebar( 'pageleft' ); ?> </aside> <section id="component" class="span6" role="main"> <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php preference_content_nav( 'nav-below' ); ?> <?php global $post; $args = array( 'numberposts' => 3, 'category_name' => Feature); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <?php the_content(); ?> <?php endforeach; ?> <?php else : ?> <article id="post-0" class="post no-results not-found"> <?php if ( current_user_can( 'edit_posts' ) ) : // Show a different message to a logged-in user who can add posts. ?> <header class="entry-header"> <h1 class="entry-title"><?php _e( 'No posts to display', 'preference' ); ?></h1> </header> <div class="entry-content"> <p><?php printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.', 'preference' ), admin_url( 'post-new.php' ) ); ?></p> </div><!-- .entry-content --> <?php else : // Show the default message to everyone else. ?> <header class="entry-header"> <h1 class="entry-title"><?php _e( 'Nothing Found', 'preference' ); ?></h1> </header> <div class="entry-content"> <p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'preference' ); ?></p> <?php get_search_form(); ?> </div><!-- .entry-content --> <?php endif; // end current_user_can() check ?> </article><!-- #post-0 --> <?php endif; // end have_posts() check ?> </section><!-- end component --> <aside id="right-column" class="span3"> <?php get_sidebar( 'pageright' ); ?> </aside> </div> <!-- .container --> <?php get_footer(); ?>
If you see anything I can do, thanks in advance.