Avi
Avi

Reputation: 161

How to show posts in custom page template in wordpress?

I am trying to make my custom page template,in which i display post with custom styles, i don't know how to show posts in this custom page template,here i am attaching my simple code for custom page template.

<?php
/*
Template Name: Custom Template
*/
get_header();

  //custom code for post is here
get_footer();
?>

Upvotes: 3

Views: 2911

Answers (2)

user4442908
user4442908

Reputation:

You can use WP_Query() to add a custom loop to your page template. You can find a few examples in the WordPress Codex

Upvotes: 3

sagar
sagar

Reputation: 590

You can always use page template similar to this and make full use of the codes over here writing with our own classes and style you are referring to :

<?php
/*
Template Name: Custom Template
*/
get_header(); ?>
<div id="primary" class="site-content">
  <div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
  <header class="entry-header">
    <?php the_post_thumbnail(); ?>
    <h1 class="entry-title"><?php the_title(); ?></h1>
  </header>

  <div class="entry-content">
    <?php the_content(); ?>
  </div><!-- .entry-content -->

  <?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
 </div><!-- #content -->

</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Upvotes: 2

Related Questions