WP get_footer function does not show footer - wordpress

I'm trying to learn how to build my own WordPress themes. I've been through a few tutorials but I've hit a snag. I can't seem to figure out what I'm doing wrong. When I have my html for my footer in the same file as my "home.php" it works fine. When I try to separate it however and place the footer html in "footer.php" and use the "get_footer();" function, the footer does not appear at all, visibly or in the code... it's not there. I am wondering if there is something else I have neglected to do to get the footer to work? If not then what could be causing the footer not to show up when I split up the code into different theme parts/files?
Here is the code for home.php:
<?php
/*
Template Name: Front Page
*/
?>
<?php get_header(); ?>
<?php get_template_part('nav'); ?>
<div id="content"><!-- Start Content -->
<?php get_sidebar('left'); ?>
<div id="middle-column" class="grid_8"><!-- Main Content Begins Here -->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?><!-- Start Loop -->
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
<div class="entrytext">
<?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
</div>
</div>
<?php
endwhile;
else:
?>
<?php _e('This page does not appear to have been set up yet. Sorry, please try again later. Thanks!'); ?>
<?php endif; ?>
<!-- End Loop -->
</div>
<?php get_sidebar('right'); ?>
<?php get_footer(); ?>
and here is the code for footer.php:
<div style="clear:both;"></div>
<div id="push"></div>
</div><!-- End Content -->
</div><!-- End Container -->
</div><!-- End Wrapper -->
<div id="footer"><!-- Start Footer -->
<div id="footWrap"><!-- Start #footWrap -->
<p>© Brent Blackwood</p>
</div><!-- End #footWrap -->
</div><!-- End Footer -->
<div id="headerBand"></div><!-- Placed here for SEO purposes -->
<div id="navBand"></div><!-- Placed here for SEO purposes -->
</body>
</html>

I don't see anything obviously wrong.
Do you have define('WP_DEBUG',true); in your wp-config.php? If not, add that and see if there are errors that might help.
Are you sure it fails at get_footer() and not before, with get_sidebar() for example?
Are your "Front Page" template file and footer.php in the same directory?
Do you have a public URL?

Related

WordPress Blog Won't Display Post Title, Meta Data, or Comments

I'm sure this is a simple fix, but I'm not much of a programmer.
I coded a WordPress site for one of my clients 3 or 4 years back. They asked to have a blog added to their site.
There are several strange things happening that I'm not entirely sure why.
If you go to: http://firstcalliowa.com/blog/
You can see it's not displaying the post title or meta data. Just the post content.
Also, go to: http://firstcalliowa.com/author/austinhudspeth/
So, this is interesting. Here, you can see the post title and edit this link. The post title isn't linked, but that can be fixed. The interesting part is, I don't have an author file made yet. So, I'm not sure why it looks more correct here, but won't pull up the post title on the first link.
Here's my loop code:
` <div id="content">
<div id="content_container">
<!-- Start the Loop. -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- Test if the current post is in category 3. -->
<!-- If it is, the div box is given the CSS class "post-cat-three". -->
<!-- Otherwise, the div box is given the CSS class "post". -->
<?php if ( in_category('3') ) { ?>
<div class="post-cat-three">
<?php } else { ?>
<div class="post">
<?php } ?>
<!-- Display the Title as a link to the Post's permalink. -->
<h2><?php the_title(); ?></h2>
<!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
<!-- Display the Post's content in a div box. -->
<div class="entry">
<?php the_content(); ?>
</div>
<!-- Display a comma separated list of the Post's Categories. -->
<p class="postmetadata">Posted in <?php the_category(', '); ?></p>
</div> <!-- closes the first div box -->
<!-- Stop The Loop (but note the "else:" - see next line). -->
<?php endwhile; else: ?>
<!-- The very first "if" tested to see if there were any Posts to -->
<!-- display. This "else" part tells what do if there weren't any. -->
<p>Sorry, no posts matched your criteria.</p>
<!-- REALLY stop The Loop. -->
<?php endif; ?>
</div>`
On the first link you provided it doesn't look like the HTML you've provided is being used. Can you do a test edit to make sure the /blog page is actually using the loop you've created? I see an empty .post-header div being outputted but I don't see that anywhere in your loop.

Make a wordpress 404 page dynamic

So I cant find and info about this, but I want to hook the default 404 page to a page thru a custom page template so that I can manage the content on the 404 page. Is this possible ?
To do this, simply create a page named 404.php in your theme.
Take a look at the simple structure of the 404.php file that is shipped with Twenty Thirteen. It basically features tags that display the header, sidebar, and footer, and also an area for your message:
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<header class="page-header">
<h1 class="page-title"><?php _e( 'Not Found', 'twentythirteen' ); ?></h1>
</header>
<div class="page-wrapper">
<div class="page-content">
<h2><?php _e( 'This is somewhat embarrassing, isn’t it?', 'twentythirteen' ); ?></h2>
<p><?php _e( 'It looks like nothing was found at this location. Maybe try a search?', 'twentythirteen' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .page-content -->
</div><!-- .page-wrapper -->
</div><!-- #content -->
</div><!-- #primary -->
So, to change the error message your visitor sees, revise the text within the h1 heading and within the page-content class; if necessary, add more paragraphs below that.
You can see more about this in the WordPress Codex.
Now to add content to this page you'll need to first create a new page in WP and tell it to use your 404 template. Once we've added page content we just need to add some code to the template php file. The following assumes that our new page has an ID of '12'.
<?php
// would get post 12's entire content after which you
// can manipulate it with your own trimming preferences
$post_12 = get_post(12);
$content = $post_12->post_content; //would echo post 12's content
//$excerpt = $post_12->post_excerpt; // would echo post 12's content up until the <!--more--> tag
?>
Now add this code into your template like so:
<?php
/**
* The template for displaying 404 pages (Not Found)
*
* #package WordPress
* #subpackage Twenty_Thirteen
* #since Twenty Thirteen 1.0
*/
get_header(); ?>
$post_12 = get_post(12);
$content = $post_12->post_content; //would echo post 12's content
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<header class="page-header">
<h1 class="page-title"><?php _e( 'Not Found', 'twentythirteen' ); ?></h1>
</header>
<div class="page-wrapper">
<div class="page-content">
<h2><?php $content ?></h2>
<p><?php _e( 'It looks like nothing was found at this location. Maybe try a search?', 'twentythirteen' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .page-content -->
</div><!-- .page-wrapper -->
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
However, assuming that you want to install this on a system where you don't know the page ID you could always create a page via your theme or plugin that uses a fixed name/title, eg: "custom-404".
Then you can change your template's code to call that post by name/title, since we always know what this is called.
$page = get_page_by_title( 'custom-404' );
//$post_12 = get_post(12);
$content = $page->post_content; //would echo post custom-404's content

Using Wordpress conditional is_page

I need help with using Wordpress conditional. The below code is the actual code I'm having problems with.
The goal is to check if the page is "bb_press" and if it is, load another template called "archive-forum".
If it's not, then continue using current template.
I tried defining if is_bbpress in the beginning, but I'm not doing something right. Perhaps the ending is the problem..
Help appreciated
<?php
if ( is_bbpress() ) {
get_template_part('archive-forum') {
else {
<--- Continue with the current template code --->
}
<?php endif;?>
<?php get_footer(); ?>
After this, I'm getting a blank page with nothing loaded.
EDIT: This is the orignal template I'm trying to modify. Without your suggestions. Tried them, but I'm doing something wrong. What am I missing here? Am I placing the "if" in the wrong place? Thank you all for your help so far.
<?php
/**
* Directory archive page
*
**/
get_header(); //Header Portion
$tmpdata = get_option('templatic_settings');
global $posts,$htmlvar_name;
do_action('after_event_header');
/* Left content side bar for all pages */
global $htmlvar_name;
if(function_exists('tmpl_get_category_list_customfields')){
$htmlvar_name = tmpl_get_category_list_customfields(CUSTOM_POST_TYPE_EVENT);
}else{
global $htmlvar_name;
}
if (!is_active_sidebar( 'tmpl_listings_left_content') ){
$class="content-middle";
}else{
$class="";
}
/* Here we use for Show left content sidebar , it can be use for many other purpose too */
do_action('tmpl_all_pages_left_content');
?>
<div class="content-sidebar <?php echo $class; ?>">
<script type="text/javascript">
var category_map = '<?php echo $tmpdata['category_map'];?>';
<?php if($_COOKIE['display_view']=='event_map' && $tmpdata['category_map']=='yes'):?>
jQuery(function() {
jQuery('#listpagi').hide();
});
<?php endif;?>
</script>
<!--taxonomy sidebar -->
<!--end taxonomy sidebar -->
<div class="page-head">
<?php
/* back page link */
tmpl_back_link();
do_action('after_directory_header'); /*do action for display the breadcrumb in between header and container. */
do_action('directory_before_container_breadcrumb');
?>
</div>
<?php
if ( is_active_sidebar('listingcategory_listing_above_content') ) : ?>
<div class="filters">
<div id="sidebar-primary" class="sidebar">
<?php dynamic_sidebar('listingcategory_listing_above_content'); ?>
</div>
</div>
<?php endif; ?>
<div class="view_type_wrap">
<?php /*do action to display the breadcrumb inside the container. */
/* Archive page title */
do_action('directory_before_archive_title'); ?>
<h1 class="loop-title">
<?php echo ucfirst(apply_filters('tevolution_archive_page_title','Listing'));?>
</h1>
<?php
if($archive_description[CUSTOM_POST_TYPE_LISTING]['description'] !=''){
?>
<div class="archive-meta"><?php echo $archive_description[CUSTOM_POST_TYPE_LISTING]['description']; ?></div>
<?php
}
do_action('directory_after_archive_title');
do_action('directory_before_loop_archive');
?>
</div>
<div id="content" class="contentarea large-9 small-12 columns <?php directory_class();?>">
<!--Start loop archive page-->
<div id="loop_listing_taxonomy" class="search_result_listing <?php if($tmpdata['default_page_view']=="gridview"){echo 'grid';}else{echo 'list';}?>" <?php if( is_plugin_active('Tevolution-Directory/directory.php') && $tmpdata['default_page_view']=="mapview"){ echo 'style="display: none;"';}?>>
<?php if (have_posts()) :
while (have_posts()) : the_post();
do_action('directory_before_post_loop');?>
<div class="post <?php templ_post_class();?>" >
<?php
/* Hook to display before image */
do_action('tmpl_before_category_page_image');
/* Hook to Display Listing Image */
do_action('directory_category_page_image');
/* Hook to Display After Image */
do_action('tmpl_after_category_page_image');
/* Before Entry Div */
do_action('directory_before_post_entry');?>
<!-- Entry Start -->
<div class="entry">
<?php /* do action for before the post title.*/
do_action('directory_before_post_title'); ?>
<div class="listing-wrapper">
<!-- Entry title start -->
<div class="entry-title">
<?php do_action('templ_post_title'); /* do action for display the single post title */?>
</div>
<?php do_action('directory_after_post_title'); /* do action for after the post title.*/?>
<!-- Entry title end -->
<!-- Entry details start -->
<div class="entry-details">
<?php /* Hook to get Entry details - Like address,phone number or any static field */
do_action('listing_post_info'); ?>
</div>
<!-- Entry details end -->
</div>
<!--Start Post Content -->
<?php /* Hook for before post content . */
do_action('directory_before_post_content');
/* Hook to display post content . */
do_action('templ_taxonomy_content');
/* Hook for after the post content. */
do_action('directory_after_post_content');
?>
<!-- End Post Content -->
<?php
/* Hook for before listing categories */
do_action('directory_before_taxonomies');
/* Display listing categories */
do_action('templ_the_taxonomies');
/* Hook to display the listing comments, add to favorite and pinpoint */
do_action('directory_after_taxonomies');?>
</div>
<!-- Entry End -->
<?php do_action('directory_after_post_entry');?>
</div>
<?php do_action('directory_after_post_loop');
endwhile;
wp_reset_query();
else:?>
<p class='nodata_msg'><?php _e( 'Apologies, but no results were found for the requested archive.', 'templatic' ); ?></p>
<?php endif;
if($wp_query->max_num_pages !=1):?>
<div id="listpagi">
<div class="pagination pagination-position">
<?php if(function_exists('pagenavi_plugin')) { pagenavi_plugin(); } ?>
</div>
</div>
<?php endif;?>
</div>
<!--End loop archive page -->
</div>
</div>
<?php get_footer(); ?>
This is correct code for your condition and will work fine. You have to close the brace for the condition. Check this for condition reference click here
<?php
if ( is_bbpress() ) {
get_template_part('archive-forum');
} else {
// continue with the current template code
}
get_footer();
?>
If you are using brackets, you do not need to use endif; This whole endif; and opening <?php and closing ?> in every row is very ugly. <!-- not valid in PHP code. And you need to add ; after get_template_part('archive-forum');
<?php
if ( is_bbpress() ) {
get_template_part('archive-forum');
} else {
//Continue with the current template code
}
get_footer();
?>
<!-- More none php code here. If there are no more php code, you can leave ?> -->

search query doesn't work on individual post pages - wordpress

From the main page and category page, my search form works just fine. Try to search for "post".
http://blog.papermusepress.com
It will bring up the results.
but if you try to do a search from within an individual post, it doesn't do the search.
try here: http://blog.papermusepress.com/my-second-post/ and search for post, it doesn't do the actual search
anybody have an idea why it would do this?
/single.php/
<?php get_header(); ?>
<div id="main">
<div id="primary">
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<div class="post-item">
<div class="title-tape">
<h2><?php the_title(); ?></h2>
<p class="meta">Posted by <?php the_author(); ?> on <?php the_date(); ?></p>
</div><!-- end title-tape -->
<?php the_content(); ?>
</div><!-- end post-item -->
<?php endwhile; ?>
<?php else : ?>
<p>We aren't sure what you are looking for..</p>
<?php endif; ?>
<div id="comments_template">
<?php comments_template(); ?>
</div><!-- end comments_template -->
</div> <!-- end primary -->
<?php get_sidebar(); ?>
</div> <!-- end main -->
</div><!-- end wrap -->
<?php get_footer(); ?>
I believe the problem is that the search query string is being appended to the full URL each time when it should only be added to the root URL. For example, if you are on http://blog.papermusepress.com/my-second-post/ the search is added to the end of that URL (instead of just http://blog.papermusepress.com/) which only allows that current page to be searched. This will keep the current template and bypass the search results page.
Check the form action in your searchform.php file. The opening form tag should look something like this:
<form method="get" id="searchform" action="<?php echo esc_url(home_url('/')); ?>">
If your form has an empty action, action="" , it will post back to itself. This can be useful, but is definitely not what you want for wordpress search.

Wordpress, custom page theme next/previos posts

I have a custom page template with code:
<?php
/*
Template Name: Featured
*/
get_header(); ?>
<div id="content_box">
<div id="content" class="posts">
<img src="http://www.dinneralovestory.com/wp-content/uploads/2010/04/favorites.png" alt="Favourites"/><br clear="all" /><br />
<?php
//The Query
$my_query = new WP_Query('category_name=favourites');
if ($my_query -> have_posts()) :
?>
<?php while ($my_query -> have_posts()) : $my_query -> the_post(); ?>
<div class="featured_box">
<div class="featured_thumb">
<?php the_post_thumbnail(); ?>
</div>
<div class="featured_content">
<span class="post_title"><?php the_title(); ?></span>
<?php the_excerpt(); ?>
</div>
</div>
<br clear="all" /><br />
<?php endwhile; ?>
<?php include (TEMPLATEPATH . '/navigation.php'); ?>
<?php else : ?>
<h2 class="page_header center">Not Found</h2>
<div class="entry">
<p class="center">Sorry, but you are looking for something that isn't here.</p>
</div>
<?php
endif;
wp_reset_query();
?>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
The navigation.php file has the previous / next code (it works fine for the standard post pages and archive pages)
navigation.php:
<?php if (is_single()) : ?>
<div class="navigation">
<span class="previous"><?php previous_post_link('← %link') ?></span>
<span class="next"><?php next_post_link('%link →') ?></span>
</div>
<div class="clear whitespace"></div>
<?php else : ?>
<div class="navigation">
<div class="previous"><?php next_posts_link('← Previous Entries') ?></div>
<div class="next"><?php previous_posts_link('Next Entries →') ?></div>
</div>
<div class="clear flat"></div>
<?php endif; ?>
I have set the maximum posts per page to 5, but the page using this theme template wont show the links. Any ideas? What code can i use to get them.
Thankyou
previous_post_link and next_post_link and the like don't make any sense for Pages. Pages are not ordered by date and time, they are hierarchical. In other words, there is no "next" Page. That doesn't make any sense in that respect.
Your base problem is that you're using a custom Page template to display Posts from a specific Category. This is the wrong way to do it, WordPress has perfectly valid category archives already, which work fine and which expect to display Posts properly.
Long story short: You will never get your Page Template approach to work 100% correctly. It just doesn't work that way. Posts were never meant to be displayed on Pages, and trying to do so only leads to things not working.

Resources