WordPress-teman : Terminologi och uppbyggnad
Hannuksela, Christa (2015)
Hannuksela, Christa
Arcada - Nylands svenska yrkeshögskola
2015
All rights reserved
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi:amk-2015052911373
https://urn.fi/URN:NBN:fi:amk-2015052911373
Tiivistelmä
WordPress har, sedan det kom ut år 2003, vuxit i popularitet till att nu, år 2015, vara det överlägset mest populära webbpubliceringssystemet. Det har därför blivit relevant att känna till hur man skapar ett utseende för en WordPress webbsida.
Det enklaste sättet att gå till väga är att skapa ett barntema, men det finns också startteman som man kan använda som grund för att sedan bygga upp ett önskat utseende. Ett ytterligare alternativ är att bygga upp filstrukturen och innehållet själv. I samtliga fall är det en fördel att man känner till den terminologi som WordPress.org använder i anknytning till teman.
Av de obligatoriska filerna som måste finnas med i ett tema som inkluderas i WordPress.org:s temakatalog finns det två filer som särskiljer sig från resten, nämligen style.css och functions.php. Style.css innehåller information om temat i en kommentar i början av filen, medan functions.php innehåller funktioner som bidrar med utökad funktionalitet till webbsidan.
Resten av de obligatoriska filerna är .php-filer som kallas mallfiler (Template Files). Dessa genererar källkoden. Vissa mallfiler genererar en del av ett HTML-dokument, andra innehåller alla komponenter som behövs för att generera ett fullständigt HTML-dokument. De senare kallas för sidmallar (Page Templates). Här förekommer en del förvirring, eftersom WordPress har egna termer för de mallfiler som genererar olika typer av sidor, så som arkivmall och sökmall, medan jag upplever att ordet sidmall skulle kunna användas för att beskriva alla filer som innehåller de komponenter som behövs för att skapa ett fullständigt HTML-dokument.
Mallfilerna innehåller PHP- och HTML-kod. En stor del av PHP-koden består av WordPress egna funktioner: Malltaggarna (Template Tags) utför åtgärder, letar fram information ur databasen eller letar efter mallfiler medan villkorstaggarna (Conditional Tags) används som villkor i if-satser. Slingan (The Loop) består av både malltaggar och villkorstaggar och behövs för att WordPress skall kunna visa olika sidor, inlägg, sökresultat o.s.v.
Den praktiska delen av mitt arbete har bestått av att jag byggt en grund för ett tema som uppfyller WordPress temagranskares krav. Min grundliga genomgång av terminologin bidrog till att detta arbete var enkelt. WordPress has, since its introduction in 2003, become the most popular CMS used by websites. It is therefore of relevance to know how to create an appearance of one’s own for a WordPress website.
The easiest way is to create a Child Theme to another theme, but there are also Starter Themes that are meant to be used as something to build from. Lastly one can create one’s own file structure and content. In all of these cases it is an advantage to know the terminology which is used in connection with WordPress themes.
Among the files that have to be included in a theme that qualifies for submission to the WordPress.org Theme Directory, two stand out from the rest: functions.php and style.css. The function file consists of functions which add functionality to the theme, while the style file contains information about the theme in a comment at the head of the file.
The rest of the files that have to be included are so called Template Files. These are .php files that generate the source code for the web pages. Some of these files generate a part of a web page, while others generate a complete web page. The latter ones are called Page Templates. Although WordPress.org differentiates between Page Templates that generate pages and Template Files that generate archives, search results etc. I prefer to use the term Page Template for all of them because they all generate complete web pages.
The Template Files contain PHP and HTML. A great part of the PHP code consists of WordPress functions: The Template Tags perform actions, look up information from the database or include the contents of Template Files, while Conditional Tags are used as conditions in if-statements. The Loop that loops through the result of a query and produces the results – single pages, posts, search result etc. – consists of both Template Tags and Conditional Tags.
In the practical part of my work I have created what could be considered my own Starter Theme. The good understanding I had gotten from reading the WordPress Codex and the Theme Handbook made my work easy.
Det enklaste sättet att gå till väga är att skapa ett barntema, men det finns också startteman som man kan använda som grund för att sedan bygga upp ett önskat utseende. Ett ytterligare alternativ är att bygga upp filstrukturen och innehållet själv. I samtliga fall är det en fördel att man känner till den terminologi som WordPress.org använder i anknytning till teman.
Av de obligatoriska filerna som måste finnas med i ett tema som inkluderas i WordPress.org:s temakatalog finns det två filer som särskiljer sig från resten, nämligen style.css och functions.php. Style.css innehåller information om temat i en kommentar i början av filen, medan functions.php innehåller funktioner som bidrar med utökad funktionalitet till webbsidan.
Resten av de obligatoriska filerna är .php-filer som kallas mallfiler (Template Files). Dessa genererar källkoden. Vissa mallfiler genererar en del av ett HTML-dokument, andra innehåller alla komponenter som behövs för att generera ett fullständigt HTML-dokument. De senare kallas för sidmallar (Page Templates). Här förekommer en del förvirring, eftersom WordPress har egna termer för de mallfiler som genererar olika typer av sidor, så som arkivmall och sökmall, medan jag upplever att ordet sidmall skulle kunna användas för att beskriva alla filer som innehåller de komponenter som behövs för att skapa ett fullständigt HTML-dokument.
Mallfilerna innehåller PHP- och HTML-kod. En stor del av PHP-koden består av WordPress egna funktioner: Malltaggarna (Template Tags) utför åtgärder, letar fram information ur databasen eller letar efter mallfiler medan villkorstaggarna (Conditional Tags) används som villkor i if-satser. Slingan (The Loop) består av både malltaggar och villkorstaggar och behövs för att WordPress skall kunna visa olika sidor, inlägg, sökresultat o.s.v.
Den praktiska delen av mitt arbete har bestått av att jag byggt en grund för ett tema som uppfyller WordPress temagranskares krav. Min grundliga genomgång av terminologin bidrog till att detta arbete var enkelt.
The easiest way is to create a Child Theme to another theme, but there are also Starter Themes that are meant to be used as something to build from. Lastly one can create one’s own file structure and content. In all of these cases it is an advantage to know the terminology which is used in connection with WordPress themes.
Among the files that have to be included in a theme that qualifies for submission to the WordPress.org Theme Directory, two stand out from the rest: functions.php and style.css. The function file consists of functions which add functionality to the theme, while the style file contains information about the theme in a comment at the head of the file.
The rest of the files that have to be included are so called Template Files. These are .php files that generate the source code for the web pages. Some of these files generate a part of a web page, while others generate a complete web page. The latter ones are called Page Templates. Although WordPress.org differentiates between Page Templates that generate pages and Template Files that generate archives, search results etc. I prefer to use the term Page Template for all of them because they all generate complete web pages.
The Template Files contain PHP and HTML. A great part of the PHP code consists of WordPress functions: The Template Tags perform actions, look up information from the database or include the contents of Template Files, while Conditional Tags are used as conditions in if-statements. The Loop that loops through the result of a query and produces the results – single pages, posts, search result etc. – consists of both Template Tags and Conditional Tags.
In the practical part of my work I have created what could be considered my own Starter Theme. The good understanding I had gotten from reading the WordPress Codex and the Theme Handbook made my work easy.