wordpress custom theme development code example
Example 1: wordpress theme development
You can use this as start theme or as boilerplate for theme
this has all the start up files
https:
Example 2: add theme support wordpress
add_theme_support( 'starter-content', array(
'widgets' => array( 'sidebar-1' => array( 'search', 'categories', 'meta'), ),
'posts' => array( 'home', 'about', 'blog' => array( 'thumbnail' => '{{image-cafe}}' ), ),
'attachments' => array( 'image-cafe' => array( 'post_title' => 'Cafe', 'file' => 'assets/images/cafe.jpg' ), ),
'options' => array( 'show_on_front' => 'page', 'page_on_front' => '{{home}}', 'page_for_posts' => '{{blog}}', ),
'theme_mods' => array( 'panel_1' => '{{about}}' ),
'nav_menus' => array( 'top' => array( 'name' => 'Top Menu', 'items' => array( 'link_home', 'page_about', 'page_blog' )), ),
) );
Example 3: 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
Example 4: wordpress theme devalopement
<?php
get_header();
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<article class="post">
<h2><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2>
<?php the_content() ?>
</article>
<?php endwhile;
else :
echo '<p>There are no posts!</p>';
endif;
get_footer();
?>