ThemeShaper Forums » Thematic

[closed]

Try to build a front-page template, but nothing is working!

(4 posts)
  • Started 3 years ago by rysch
  • Latest reply from kwight
  • This topic is not resolved
  1. Hi,

    I'm trying to build a front page template that will have a jQuery featured page/post slider, three widget areas and a section that will list the latest three posts from the blog.

    But I'm running into trouble. Initially, I had the jQuery gallery called through Functions.php but then I decided to pull that out of functions and put it directly into the page template. So this is what I have in my page template right now.

    <?php
    /*
    Template Name: Front Page
    .
    Take a look at the functions.php for this theme to see how the random content is included.
    .
    */
    ?>
    <?php get_header() ?>
    <div id="gallery">
    	<div id="gallery-container">
    		<?php dynamic_content_gallery(); ?>
    </div><!--leader-contianer-->
    </div><!--leader-->
    <div id="container">
    			<div id="content">
                <?php
    				$recentPosts = new WP_Query();
       				$recentPosts->query('showposts=3');
    				while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
    				<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
    				<div class="meta">
    					By <?php the_author() ?>
    				</div>
    				<div class="storycontent">
    					<?php the_excerpt(); ?>
    				</div>
    			<?php endwhile; ?>
    			</div><!-- #content -->
    
    		</div><!-- #container -->
    
    <?php get_footer() ?>

    The problem is, now nothing is showing up except for the menu, the blog title and blog description (the CSS is still being worked on so it doesn't look pretty right now and may not work all that great, yet)

    Here is what it looks like: http://www.ctrchurch.com/test

    I have pulled the code for the three widget areas out of the Thematic Powerblog child theme.

    This is what I have in Functions.php

    // Register new widgetized areaa and the new widgets
    function childtheme_widgets_init() { 
    
        register_sidebar(array(
           	'name' => '1st leader Aside',
           	'id' => '1st-leader-aside',
           	'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
           	'after_widget' => "</li>",
    		'before_title' => "<h3 class=\"widgettitle\">",
    		'after_title' => "</h3>\n",
        ));  
    
        register_sidebar(array(
           	'name' => '2nd leader Aside',
           	'id' => '2nd-leader-aside',
           	'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
           	'after_widget' => "</li>",
    		'before_title' => "<h3 class=\"widgettitle\">",
    		'after_title' => "</h3>\n",
        ));  
    
        register_sidebar(array(
           	'name' => '3rd leader Aside',
           	'id' => '3rd-leader-aside',
           	'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
           	'after_widget' => "</li>",
    		'before_title' => "<h3 class=\"widgettitle\">",
    		'after_title' => "</h3>\n",
        ));   
    
        // Register the new widgets
        register_sidebar_widget('Thematic Power Blog Subscribe', 'thematic_power_blog_subscribe');
    
    }
    add_action( 'init', 'childtheme_widgets_init' ); 
    
    // Add a widgetized aside just below the main content
    function childtheme_leaderasides() { ?>
    <?php if (is_page_template('front-page.php')) { ?>
        <?php if ( is_sidebar_active('1st-leader-aside') || is_sidebar_active('2nd-leader-aside') || is_sidebar_active('3rd-leader-aside') ) { // one of the leader asides has a widget ?>
        <div id="notice">
            <div id="notice-container">
    
                <?php if ( function_exists('dynamic_sidebar') && is_sidebar_active('1st-leader-aside') ) { // there are active widgets for this aside
                    echo '<div id="first-leader" class="aside sub-aside">'. "\n" . '<ul class="xoxo">' . "\n";
                    dynamic_sidebar('1st-leader-aside');
                    echo '</ul>' . "\n" . '</div><!-- #first-leader .aside -->'. "\n";
                } ?>                
    
                <?php if ( function_exists('dynamic_sidebar') && is_sidebar_active('2nd-leader-aside') ) { // there are active widgets for this aside
                    echo '<div id="second-leader" class="aside sub-aside">'. "\n" . '<ul class="xoxo">' . "\n";
                    dynamic_sidebar('2nd-leader-aside');
                    echo '</ul>' . "\n" . '</div><!-- #second-leader .aside -->'. "\n";
                } ?>       
    
                <?php if ( function_exists('dynamic_sidebar') && is_sidebar_active('3rd-leader-aside') ) { // there are active widgets for this aside
                    echo '<div id="third-leader" class="aside sub-aside">'. "\n" . '<ul class="xoxo">' . "\n";
                    dynamic_sidebar('3rd-leader-aside');
                    echo '</ul>' . "\n" . '</div><!-- #third-leader .aside -->'. "\n";
                } ?> 
    
            </div><!-- #leader-container -->
        </div><!-- #leader -->
        <?php } ?>
    
    <?php } }
    add_action('thematic_abovefooter','childtheme_leaderasides',6);

    So why are none of these three elements showing up now?

    Oh, and now the footer isn't showing up.

    Gah! I keep breaking this!

    Posted 3 years ago #
  2. Just a little update...

    So right now, I removed this from the template I'm working on...

    <div id="container">
    			<div id="content">
                <?php
    				$recentPosts = new WP_Query();
       				$recentPosts->query('showposts=3');
    				while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
    				<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
    				<div class="meta">
    					By <?php the_author() ?>
    				</div>
    				<div class="storycontent">
    					<?php the_excerpt(); ?>
    				</div>
    			<?php endwhile; ?>
    			</div><!-- #content -->
    
    		</div><!-- #container -->

    And now the JQuery gallery shows up fine. The three widget areas that are put in via functions.php show up fine.

    So I guess the question is, how do I display the following without screwing up again:

    1. I want to show three posts in this front-page-template.
    2. I only want to show excerpts of the post.

    Thanks so much in advance!

    Posted 3 years ago #
  3. when you make a new WPQuery you get rid of the old one and stuff gets complicated. WP doesn't know any more than you're on the template where your widgets are supposed to appear, etc.

    i almost always try to use get_posts
    codex.wordpress.org/Function_Reference/get_posts

    you can make almost exactly the same loop (there is a good example on the codex page)

    Posted 3 years ago #
  4. kwight
    Member

    You can also avoid the whole WP_query mess by using:

    query_posts('posts_per_page=3');

    right before your loop (http://codex.wordpress.org/Function_Reference/query_posts). It seems similar to get_posts (which I've never used), but meant just for the main loop (as opposed to get_posts being used for multiple loops?..)

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.