SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
@pixolin
MeetUp Köln
Themes ändern,
aber richtig
Child Themes &
Template Hierarchy
© Monica Holli/flickr/CC BY
@pixolin
MeetUp Köln
Das Theme gefällt mir soweit ganz gut, aaaber …
Wie werde ich "Dieser Beitrag wurde unter 

Allgemein abgelegt am 16. Juni, 2014." wieder los?
Und wie ändere ich die Schriftart?
@pixolin
MeetUp Köln
Bitte nicht …
Theme direkt ändern:
• wird bei Update
überschrieben
• Änderungen/Original 

sind schlecht
auseinanderzuhalten
@pixolin
MeetUp Köln
Bitte nicht …
Design > Editor verwenden:
• Macht unter Umständen
die Website unbrauchbar! 



Beispiel: 

"White Screen of Death"
bei function bla( {}
da fehlt was
@pixolin
MeetUp Köln
Child Themes
@pixolin
@pixolin
MeetUp Köln
Child Theme, Definition
Ein WordPress Child Theme ist ein
Theme, das die Funktionalität eines
anderen Themes, des so genannten
Parent Themes, erbt.
Child Themes sind Ergänzungen, bzw.
Ersetzungen des Parent Themes. 

Sie sind ohne Parent Theme nicht
verwendbar.
@pixolin
MeetUp Köln
Bitte nicht …
Komplettes Parent Theme
oder komplette style.css
kopieren
Das Child Theme soll das
Parent Theme ergänzen!
(aber: Templates kopieren 

ist erlaubt.)
@pixolin
MeetUp Köln
Woraus besteht ein Child Theme mindestens?
header.php index.php style.css
mit Template Header und 

Verweis auf Parent Theme!
@pixolin
MeetUp Köln
Template Header
/*
Theme Name: Twenty Fourteen Child
Theme URI: http://example.com/twenty-fourteen-child/
Description: Twenty Fourteen Child Theme
Author: John Doe
Author URI: http://example.com
Template: twentyfourteen
Version: 1.0.0
Tags: light, dark, two-columns, right-sidebar,
responsive-layout, accessibility-ready
Text Domain: twenty-fourteen-child
*/
!
@import url("../twentyfourteen/style.css");
!
/* =Theme customization starts here
--------------------------------------------------------------
*/
@pixolin
MeetUp Köln
Template Header (mindestens!)
/*
Theme Name: WP Meetup Köln
Template: twentytwelve
*/
!
@import url("../twentytwelve/
style.css");
!
/* =Theme customization starts here
-------------------------------- */
@pixolin
MeetUp Köln
Cascading Style Sheets
heißen so, weil sie in einer
verschachtelten HTML-
Struktur eine Style-Regel so
lange vererben, bis der Wert
durch eine andere Regel
überschrieben wird.
@pixolin
MeetUp Köln
<html>
<head>
</head>
<body>
<h1></h1>
<p></p>
<p><span class="wichtig"></span></p>
</body>
</html>
"Cascades" © Darren Johnson/flickr/CC BY
@pixolin
MeetUp Köln
body { color: #333; } 

gilt für alle nachfolgenden
Selektoren, sofern keine
spezifischere Regel greift
.wichtig { color: #d12525; }
@pixolin
MeetUp Köln
Wiederholen sich Regeln,
überschreibt das zuletzt
geladene Style Sheet die
vorherigen
<link rel="stylesheet" type="text/css" 

href="reset.css">
<link rel="stylesheet" type="text/css" 

href="style.css">
<link rel="stylesheet" type="text/css" 

href="mein-style.css">
@pixolin
MeetUp Köln
Template Header
/*
Theme Name: WP Meetup Köln
Template: twentytwelve
*/
!
@import url("../twentytwelve/style.css");
!
/* Google Web Font Dancing Script */
@import url(http://fonts.googleapis.com/css?
family=Dancing+Script);
!
.site-header h1 a { font-family: 'Dancing
Script', cursive; }
@pixolin
MeetUp Köln
Template Hierarchy
WordPress versucht immer, das 

"am besten geeignete" Template zu
verwenden. Beispiel: Kategorie "Hobbits"
category.php

?
archive.php

?
index.php

!
category-
hobbits.php

?
@pixolin
MeetUp Köln
http://codex.wordpress.org/Template_Hierarchy
@pixolin
MeetUp Köln
http://codex.wordpress.org/Template_Hierarchy
@pixolin
MeetUp Köln
@pixolin
MeetUp Köln
front-page.php
Unter Einstellungen > Lesen kann man
festlegen, was als Startseite angezeigt
wird.
Statische Seite	 ➛	 front-page.php

Blogseite	 ➛	 home.php
Existiert das Template nicht, 

kann man es anlegen!
@pixolin
MeetUp Köln
Templates ändern?
• Mit Plugin (z.B. "What The File")
nachschauen, welches Template für
die Anzeige verwendet wird.
• Template kopieren, nach Text suchen
und HTML editieren.
• Wird der Text mit einer theme-
eigenen Funktion erzeugt/verändert?
@pixolin
MeetUp Köln
Fatal error
Petit Grenouille, © webhamster/Flickr/CC BY
@pixolin
MeetUp Köln
PHP erlaubt nicht, 

zuvor deklarierte
Funktionen neu zu
definieren oder die
Definition zu löschen.
@pixolin
MeetUp Köln
Fatal error
Kopieren der
kompletten

functions.php 

führt häufig zu einem 

Fatale error, weil
(mindestens) ein
Funktionsname
doppelt vorkommt.
@pixolin
MeetUp Köln
Fatal error: Lösung 1
Das Parent Theme ist darauf
vorbereitet und verwendet
if( ! function_exists(…) )

bzw.	
if( ! isset(…) )
@pixolin
MeetUp Köln
Fatal error: Lösung 2
Funktionen werden in WordPress
Schnittstellen hinzugefügt
add_action('hook', 'function');
und lassen sich genauso auch wieder entfernen
remove_action('hook', 'function');
anschließend eigene Funktion hinzufügen
add_action( 'hook', 'myfunction' );
@pixolin
MeetUp Köln
@pixolin
MeetUp Köln
Happy Child Theming!
Two children playing with a seated older man. © Boston Public Library/Flickr/CC BY
M
G!Heute

Contenu connexe

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Childthemes 2