Skip to content

A WordPress theme inside an .org file. Meant to be "tangled" with org-mode and org-babel in Emacs.

Notifications You must be signed in to change notification settings

cryptstopher/freerun-theme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Freerun

A Different Way to Write Wordpress

This file contains individual source code blocks that, together, build a WordPress Theme.

This is a literate programming document, which basically means that it is a written document with a computer program nested in its body. The code snippets are extracted from this document and “tangled” together to build the final program.

Reproducible

If you accidentally delete all of your theme files, or want to reproduce them on another workstation or WordPress site, all you need is the README file, and you can rebuild the theme.

Dependencies

In order to proceed with this project you will only need:

Installation

  1. Install Emacs (if you haven’t already)
  2. Open README.org file
  3. Type key command C-c C-v C-t to initiate the org-babel-tangle function

(In Emacs, the “C” represent the control key on your keyboard.)

Theme Files

The “freerun” theme consists of four files:

WordPress theme boilerplate stylesheet

Every WordPress themes starts with the style.css file, containing the theme information:

/*
Theme Name: freerun
Author: Chris M
Version: 1.0
*/

body {
    margin-left: 8%;
    margin-right: 8%;
}

/*
#headerimg h1 {
    font-family: fantasy;
}
#headerimg a {
    text-decoration: none;
    color: black;
}
#headerimg a:hover {
    text-decoration: none;
    color: #14cc17;
}
.description {
    margin-top: -20px;
}
*/

Index file

The index.php file uses the WordPress “loop” to cycle through published posts.

<?php

get_header();

if (have_posts()) :
    while (have_posts()) : the_post(); ?>
	   <h2>&bull; <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?>

    <?php endwhile;

    else :
	   echo '<p>No content found</p>';

    endif;

get_footer();

?>

Single post template

The single.php template generates content for a single post.

<?php

get_header();

if (have_posts()) :
	 while (have_posts()) : the_post(); ?>

		 <h1><?php the_title(); ?></h1>
		 (<?php the_date(); ?>)
		 <?php the_content(); ?>

	 <?php endwhile;

else :
	 echo '<p>No content found</p>';

endif;

get_footer();

?>

Page template

The page.php file generates the content for a single page.

This page template includes some special code to generate a list of “child” pages (if there are any). WordPress pages are “hierarchical,” which means you can nest pages underneath other pages.

<?php

get_header();

if (have_posts()) :
	 while (have_posts()) : the_post(); ?>

		 <h1><?php the_title(); ?></h1>
		 <?php the_content(); ?>

        <!--List child pages (if there are any)-->

		 <?php
		 $children = wp_list_pages( 'title_li=&child_of='.$post->ID.'&echo=0' );
		 if ( $children) : ?>
			 <ul>
				 <?php echo $children; ?>
			 </ul>
		 <?php endif; ?>

	 <?php endwhile;

else :
	 echo '<p>No content found</p>';

endif;

get_footer();

?>

Shell Code Examples

For demonstration purposes, this following code block allows for shell commands. No tangle argument here, any shell commands that you run from here will not affect the theme files. However, a “results” argument with parameter “raw” will echo the raw output in the buffer.

Add PHPUnit to your project using Composer (may take a minute or so):

/usr/local/bin/composer require --dev phpunit/phpunit ^9

Get the version:

./vendor/bin/phpunit --version

About

A WordPress theme inside an .org file. Meant to be "tangled" with org-mode and org-babel in Emacs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published