Today we talked about CMS’s in more details, specifically we talked about WordPress.
We talked about how to modify a CMS. WordPress has two concepts:
- Theme – Made up of many parts to produce a general look, feel and sense of what that particular instance of WordPress will do. Theme can contain many templates.
- Template – Shape of a page. Output from WordPress
The filepath to themes in WordPress is:
When you make a new theme you are actually making a new directory in the themes directory. The default themes tend to use a bootstrap layout.
When you write a theme and template in WordPress you must stick to the style of the WordPress document. You must also include WordPress in the licensing.
The PHP notation uses elements from Python. e.g.
<? php if ( have_posts() ) : ?> — python notation
The colon means we have a conditional block following.
WordPress uses a loop to gather information to gather information for that particular page or command to get appropriate content.
get_template_part (‘content’, get_post_format))
This will look for a file with the prefix ‘content’ e.g. content-page.
get_template_part(‘content’,’none’); This will look for and display content-none.php.
WordPress hands the browser a external style sheet and then the web browser checks for the page header element to find the styles to apply for that element.
WordPress is a framework designed for blogging as ‘posts’ are still referred to in the code templates.
Each template in a theme control a specific part of the theme. The templates are not static you can hack (modify) the template code to change the theme.
The index file control controls what the home page looks like. It contains a loop which retrieves and displays the most recent post.
index.php shows a list of posts.
A single post page – which appears when the user click on a post in index.php.
single.php uses a loop. This loop is a query that displays the content, it is a retrieve and generate.
You can implement sidebars to look different to
This controls what wordpress pages look like. THis is the WordPress concept of a page not the webpage as a whole.
WordPress lets you make different page templates for different types of pages.
Template Name: YourNameHere
archive.php, category.php, tag.php
Archive.php changes the look of the archive area in WordPress.
Category overrides for category
tag.php is more detailed than other two this allows you to override tags.
Has a query to determine the posts/pages to grab. ends with php end while statement.
Loop is like template for generating output from query.
You can have multiple loops on a single page, to retrieve and display other information. Such as other related posts.
The loop can find fields and template tags to display in the loop.
WordPress is a system Everything from db to be displayed is retrieved by the loop. To include comments you must include comments.php in the loop, you can do this by writing in query to retrieve comments.php in between the start of loop and endwhile statement.
Make your own theme
To make a theme to match the organizational branding of a client then you would need to edit the style.css which is the main WordPress style sheet.
You can make a child theme to customize a theme that you like.
You can have a template without a template as your can have page.php with sidebar .php template within that template.
We then worked on customizing the blankslate theme to make our own theme.