Reputation: 1955
I am working on a Wordpress 3.9.1 website with the Twenty Fourteen theme. Normally the theme lets me choose from 3 different templates it has for every page which are Default - Full-Width - Contributor Page.
For the home page I am using full-width template which also calls another template part called content-page.php
I created another file called content-pagehome.php and copied everything from content-page.php and added some content inside like this;
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> class="homepage-content-styles">
<?php
// Page thumbnail and title.
twentyfourteen_post_thumbnail();
the_title( '<header class="entry-header"><h1 class="entry-title">', '</h1></header><!-- .entry-header -->' );
?>
<div class="entry-content">
<?php
the_content();
wp_link_pages( array(
'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfourteen' ) . '</span>',
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
) );
edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' );
?>
</div><!-- .entry-content -->
<!-- This is the part I've added -->
<div style="margin-top:7%;">
<h5 style="margin-left:5%;"><a title="Buscas hotel en Costa Rica?" href="http://veranta.com/country/costa-rica-hotels/buscas-hotel-en-costa-rica/">Hoteles en Costa Rica</a></h5>
<h5 style="margin-left:5%;"><a title="Buscas hotel en Panama?" href="http://veranta.com/country/ofertas-y-hoteles-en-panama/buscas-hotel-en-panama/">Hoteles en Panama</a></h5>
<h5 style="margin-left:5%;"><a title="Buscas hotel en Nicaragua?" href="http://veranta.com/country/book-nicaragua-hotels/buscas-hotel-en-nicaragua/">Hoteles en Nicaragua</a></h5>
<h3 style="text-align: center; margin-left:4%; margin-top:10%;"><strong>Veranta trabaja con los mejores proveedores de reservaciones de la región <br class="none" /> y directamente con hoteles, B&B, y condominios para conseguir <br class="none" /> la mejor oferta de hoteles de Centroamérica.<br class="none" /> Compare cientos de precios en solo lugar<br class="none" /> y ahorre en sus reservaciones de hotel.</strong></h3></div>
</article><!-- #post-## -->
And then in the full-width.php I've changed the statement where it calls content-page.php to an if else statement;
get_header(); ?>
<div id="main-content" class="main-content">
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
// Include the featured content template.
get_template_part( 'featured-content' );
}
?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
//if it is home get template part content-page-home.php else get content-page.php
if ( is_home() ) {
// Include the page content template.
get_template_part( 'content', 'pagehome' );
} else {
get_template_part( 'content', 'page' );
}
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>
</div><!-- #content -->
</div><!-- #primary -->
</div><!-- #main-content -->
<?php
get_sidebar();
get_footer();
The website is online here veranta.com I can add more information if needed!
Still it is not calling the content-pagehome.php. I have cleared my caches etc. and checking which templates it uses from admin panel thanks to what the file plugin.
Can you see anything wrong here? Any help would be really useful. Thanks for your time!
Upvotes: 1
Views: 268
Reputation: 1955
Found the problem, still want to keep this question as a reference for others.
There are two different boolean functions which are is_home()
and is_front_page()
.
is_front_page()
is the right option in my case because I have a static page displaying on the Front Page and in the function reference it says:
It returns TRUE when the main blog page is being displayed and the Settings->Reading->Front page displays is set to "Your latest posts", or when is set to "A static page" and the "Front Page" value is the current Page being displayed.
If I had a Blog Post Index ("Your Latest Posts" option at Customize)
I would need to use is_home()
as it says in the reference:
is_home()
checks if the blog posts index page is being displayed as the Front Page.
I still can't close this question cause I can't accept my answer in two days. If you think that this has to be closed, please vote for it.
Thanks.
Upvotes: 1