user5365803
user5365803

Reputation:

Custom Template For Page in wordpress

Is there away to Create a custom php template for a page this is not the front page

For Example: When you have front-page.php for the homepage i want to do some thing like that.

I don't Know if this is possible but if it is Thank You for your answers

Upvotes: 0

Views: 48

Answers (1)

Adi Nugroho
Adi Nugroho

Reputation: 161

This code you can use to create a custom template:

<?php
/**
 * Template Name: Alphabetical Posts
 */

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
        $custom_posts = new WP_Query( array(
            'order_by' => 'title',
            'order'    => 'asc'
        ));
        if ( $custom_posts->have_posts() ) :
            while ( $custom_posts->have_posts() ) : $custom_posts-    >the_post();
                get_template_part( 'content', get_post_format() );
            endwhile;
            twentyfourteen_paging_nav();
        else :
            get_template_part( 'content', 'none' );
        endif;
    ?>

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

<?php
get_sidebar();
get_footer();

the snipet is from https://premium.wpmudev.org/blog/creating-custom-page-templates-in-wordpress/

Upvotes: 1

Related Questions