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.
I’m not quite sure what you are trying to do, but you are trying to add a left sidebar column for a three column page layout? I should also mention that I only cover support for the theme itself and not for custom changes someone does…but if you are indeed wanting a three column page layout, my Pro version has that.
As for that extra space, this is what shows up in the source code before your post (but shouldn’t be there)
<div class="row-fluid"> <div class="span12"> </div> </div>
Ultimately, your code you did is not done correctly. You may want to check out tutorials for what you are trying o do and then create a new template. First thing that is important is to create your structure first (the divs, etc). Then the actual article content (from one of the template iles) is this:
<?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'page' ); ?> <?php comments_template( '', true ); ?> <?php endwhile; // end of the loop. ?>
The get_template line goes to grab the “content” file content-page.php which then loads the actual post content with this line:
<?php the_content(); ?>
Yes – adding a sidebar on the left was my goal. I was sure the coding was not kosher, and couldn’t believe I got a semblance of what I was striving for. I have no idea where to start with learning about CSS and php files. Every tutorial I’ve found presumes that I already know something. I’m an old-hat html person who has never investigated css or php, much less template websites such as WordPress. I suppose I will invest in a css-for-dummies book. Thanks for taking a look at the coding.
I hear you on the tutorial part… Seems to be a lot of tutorials out there that assumes a person already has more than a basic understanding of PHP. The ones that focus on absolute beginners is hard to find but they are out there. Might want to check http://wp.tutsplus.com/ as well. For HTML and CSs, check out http://www.w3schools.com Then for understanding WP basics, check out wp101.com as well. Try to avoid spending money on books if you can but if there is one that appeals to you, go for it.
Thanks for the pointers. I just surveyed 8 other themes and none of them give the flexibility and potential that Preference Lite has. While I need to explore css coding for my own enlightenment, I don’t have the time right now. I will be upgrading to Preference Pro – unless I find one I like better after I look at your other themes. Your support has been extremely helpful and the Preference Lite theme has allowed me to be very creative within my admitted limitations. You do great work!
- The topic ‘Fiddled with the front page’ is closed to new replies.