wordpress customizer code example

Example 1: 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(); ?>

Example 2: wordpress custom theme

//créer wp-content/themes/myThemeName/style.css
/*
Theme Name: Capitaine
Theme URI: https://capitainewp.io
Author: Maxime BERNARD-JACQUET
Author URI: https://dysign.fr
Description: Mon premier thème !
Requires at least: WordPress 5.0
Version: 1.0
*/

//créer wp-content/themes/myThemeName/index.php
<?php
	$echo = "content"
?>
<!DOCTYPE html>
<html>
<head></head>
<body>
	<h1>Coucou ! <?php echo$echo ?></h1>
</body>
</html>


//That's all, go to theme in /wp-admin web interface, 
//and select "Capitaine" theme in 'Appearence' dashboard menu to activate your brand new wordpress theme

Tags:

Misc Example