Problems with Specialized Page Templates
-
Hi everyone,
I am currently experiencing some issues with creating Specialized Page Templates. Seems simple enough, even to me, but I just can not get it to work. I was hoping someone here could help me out!
So this is what I’m trying to achieve: I have created a homepage,
index.php
, and I have created several Pages I want to customize, including the Articles Page,http://www.mysite.com/articles/
(permalink). The goal is to display the 3 latest posts onindex.php
, among other things, and to display all posts, let’s say, 10 per page, on the/articles/
Page.My idea was to create a custom template for the
/articles/
Page in my theme,page-articles.php
, and paste in the same code as for myindex.php
file and simply change thewhile (have_posts())
condition in my loop (I figured I could easily bypass the global “X posts per page” setting under Dashboard > Settings > Reading > Blog pages show at most X posts by using the technique on this tutorial (method 1)). This, however, did not work; the/articles/
Page did display ‘test, test’ HTML content I added inpage-articles.php
, but did not show any posts fromThe Loop
, which I had definitely called in that file; instead, the page layout was formatted exactly like the standardpage.php
theme template file. That’s strange, where did it get this formatting? I did not define this inpage-articles.php
?Just so I did not have to deal with the above issues, I decided to change my tactics and try and use Conditional Tags to do the trick by editing the
content.php
theme file, which contains The Loop:<div id="content" role="main"> <?php if ( !is_home() ) { if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part( 'entry' ); comments_template(); endwhile; endif; get_template_part( 'nav', 'below' ); } else { $i = 0; while ( have_posts() && $i < 3) : the_post(); get_template_part( 'entry' ); comments_template(); $i++; endwhile; get_template_part( 'nav', 'below' ); } ?> </div>
However, this yields not only my
index.php
, but also my/articles/
Page to display only 3 posts (whereas/articles/
should display 10, because I changed the Blog pages show at most X posts setting to this value).I am at a loss. Does anybody know how to solve the issues with Specialized Theme Templates, or does anybody have a solution for the problem I’m having with Conditional Tags? Any help would be sincerely appreciated. Thanks in advance!
- The topic ‘Problems with Specialized Page Templates’ is closed to new replies.