Ive created my first wp-theme, my front page is dynamic with posts etc. I want to create a page that is diffrent than the main one. A page template that has static content as the main content and posts on the side. example; I want to create an about us page and have a static text that tells the audience what we do but I also want posts on the side. Ive created the dynamic part of the page but I’m having trouble with the static part.
This is how the dynamic part looks like:
<div class="latest-posts eightcol">
<?php the_post(); ?>
<article class="post">
<h2><a title="<?php the_permalink(); ?>"> <?php the_title(); ?></a></h2>
<div class="entry-meta links-turquoise">
<?php the_time('F j, Y'); ?> —
<span class="author"> <?php the_author(); ?>utvecklare</span>
</div><!-- .entry-meta .links-turquoise -->
<div>
<?php the_content(); ?>
</div>
</article>
</div><!-- .latest-posts .eightcol -->
What I dont know how to write is the static part. I want to create this template so that I can apply the same layout to more then one page.
I hope you understand what I’m looking for.
Thank you
to create a page template all you need is to add the name of the template as a comment in the top of the template file like so:
It will then be recognized by your wordpress editor, and you’ll be able to choose it as a page template
You can load the page static content before you load the posts, that is before the loop, simply by calling
the_post()
andthe_content()
since the default post is the page that was loaded. (tryvar_dump($post)
and see for yourself). In case you want to call it after the loop you can usewp_reset_query();
to return to the starting point