Answers for "template name: wordpress"

PHP
1

get template name wordpress

get_page_template_slug()

if (get_page_template_slug() =='page-workflow.php' ) {
  //stuff
}
Posted by: Guest on April-15-2020
2

create custom page template wordpress

/*           make this file in template-parts folder 
                 give file name as category_post.php        */

<?php
/**
 * Template Name: Category Custom Page
 */
 
get_header(); ?>
 
<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">
 
    <?php
    $args = array(
        'post_type' => 'post',
        'post_status' => 'publish',
        'category_name' => 'wordpress',
        'posts_per_page' => 5,
    );
    $arr_posts = new WP_Query( $args );
 
    if ( $arr_posts->have_posts() ) :
 
        while ( $arr_posts->have_posts() ) :
            $arr_posts->the_post();
            ?>
            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <?php
                if ( has_post_thumbnail() ) :
                    the_post_thumbnail();
                endif;
                ?>
                <header class="entry-header">
                    <h1 class="entry-title"><?php the_title(); ?></h1>
                </header>
                <div class="entry-content">
                    <?php the_excerpt(); ?>
                    <a href="<?php the_permalink(); ?>">Read More</a>
                </div>
            </article>
            <?php
        endwhile;
        wp_pagenavi(
            array(
                'query' => $arr_posts,
            )
        );
    endif;
    ?>
 
    </main><!-- .site-main -->
</div><!-- .content-area -->
 
<?php get_footer(); ?>
Posted by: Guest on November-13-2020
1

wordpress define template name

/*on top of Php file add the below line to make as custom template*/

<?php /* Template Name: Custom template name */ ?>
Posted by: Guest on December-11-2020

Code answers related to "template name: wordpress"

Browse Popular Code Answers by Language