SlideShare ist ein Scribd-Unternehmen logo
1 von 47
Downloaden Sie, um offline zu lesen
Creating and Displaying
Custom Post Types
Welcome to my WordPress Lab.
This is where I test WP stuff.
***
Today we are going to create
a Custom Post Type called Portfolio.
If I have to write more than 4 lines of code, my head explodes
Plugin:

Custom Post Type UI
C r e at e

D i s p l ay

Custom Post Type called Portfolio
Here’s what it will look like

Demo
Let’s Create
c r e a t e : P o r t f o li o

Download
Install
Activate

And here it is
Add New
c r e a t e : P o r t f o li o

portfolio

Portfolio
c r e a t e : P o r t f o li o

Advanced Options

Change to True

Scroll down to continue
c r e a t e : P o r t f o li o
c r e a t e : P o r t f o li o

Next: Create a Taxonomy
work_type

Work Type
c r e a t e : P o r t f o li o

Associate Taxonomy with Portfolio
c r e a t e : P o r t f o li o
Show the posts you have created

Demo
The first time = 404

Settings>Permalinks and then update your present permalink structure
by just clicking on the Save Changes button
Learn to Display
CPT : What is it?
It’s not a post. But it acts like a post
 It displays content on a Single post page
 It can display content on an Archive page

It’s not a page. But it acts like a page
 It’s not heirarchical
 You can assign it a page template
 Normally, it can’t access categories that were
created by the Post
D ispl a y : T e m pl a t e s

single.php
Start with 3 exisiting files

archive.php
taxonomy.php
D ispl a y : T e m pl a t e s

single-portfolio.php
Add a slug to the name

archive-portfolio.php
taxonomy-work_type.php
See, it really works
Demo
th e m a g ic o f :

Template Hierarchy
a r chi v e p o st :

si n g l e p o st :

T a x o n o m y p o st :

archive-portfolio.php

single-portfolio.php

taxonomy-work_type-logo.php

archive.php

single.php

taxonomy-work_type.php

index.php

index.php

taxonomy.php
archive.php
index.php
SoWhy?
To make your CPT posts look different
from your single and archive posts
that appear in your blog.
D ispl a y : M o di f y th e t e m pl a t e

taxonomy-work_type.php

Page Title

Thumbnail

Post Title
get_header(); ?>
		<section id=”primary” class=”content-area”>
		 <div id=”content” class=”site-content” role=”main”>

the loop

	 <?php if ( have_posts() ) : ?>
	 <?php
	 while ( have_posts() ) : the_post();?>
	 <?php endwhile;
		twentyfourteen_paging_nav();
	 else :
		 get_template_part( ‘content’, ‘none’ );
	endif;
	?>
		</div><!-- #content -->
		 </section><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
<?php if ( have_posts() ) : ?>
			<h1 class=”tax-title”><span>Work Type: </span>

Page Title

				<?php $term_list = wp_get_post_terms($post->ID, ‘work_type’, array(“fields” => “names”));
				$x = $term_list[0];
				echo “$x”;
				?>
			</h1>
	
<?php
	
while ( have_posts() ) : the_post();?>
		<div class=”grid”>

Thumbnail
Post Title

			<?php echo the_post_thumbnail(‘portfolio-thumb’); ?>
			<h4><a href=”<?php the_permalink(); ?>”> <?php the_title(); ?></a></h4>
		</div>
	
<?php endwhile;
		twentyfourteen_paging_nav();
	
else :
		
get_template_part( ‘content’, ‘none’ );
	endif;
	?>
D ispl a y : m o di f y th e T e m pl a t e s

https://codex.wordpress.org/
the_post_thumbnail(); // without parameter -> ‘post-thumbnail’
the_post_thumbnail(‘thumbnail’); // Thumbnail (default 150px x 150px max)
the_post_thumbnail(‘medium’); // Medium resolution (default 300px x 300px max)
the_post_thumbnail(‘large’); // Large resolution (default 640px x 640px max)
the_post_thumbnail(‘full’); // Full resolution (original size uploaded)

functions.php
//Enable support for Post Thumbnails
add_image_size( ‘portfolio-thumb’, 250, 250, true );
More Display Fun
CSS and the Body Class

Thank you Becky Davis
D ispl a y : C S S a n d B o d y cl a ss

H1.page-title
D ispl a y : C S S a n d B o d y cl a ss

Use chrome inspector tool to find body class

class = .post-type-archive-portfolio
D ispl a y : C S S a n d B o d y cl a ss

.post-type-archive-portfolio #primary h1.entry-title
{
font-weight:700; font-size:15px; letter-spacing: .15em;
border: 1px #ccc dotted; padding: 20px;
}
Sidebar Navigation
Shows links to Work Type Terms
D ispl a y : sid e b a r



Custom Sidebars



Taxonomy* List Widget

2 Plugins

*Posts use Categories // Custom Post Types use Taxonomy/Terms
D ispl a y : S id e b a r

Custom Sidebars

Taxonomy List Widget

Work Type

Work Type
Let’s see the sidebar in action
Demo
Another way to Display:

Page Template!
bye bye archive-portfolio.php
Why a Page?
 More control with design
 Easier to add to a menu
 Easier to add custom sidebars
D ispl a y : T e m pl a t e s / P AGE

Look Familiar?
Duplic ate:

	

page.php

	Rename:

	

page-portfolio.php

	

/* Template Name: Portfolio Page*/

	

	Op en an d Add:
D ispl a y : T e m pl a t e s / P AGE
D ispl a y : T e m pl a t e s / P a g e

Add php code to the template

Use a Plugin: Grid FX

<?php
$args = array( ‘post_type’ => ‘portfolio’, ‘posts_per_page’ => 10 );
$loop = new WP_Query($args);
?>
<?php
while ( $loop->have_posts() ) : $loop->the_post();
get_template_part( ‘content’, get_post_format() );
endwhile;
twentyfourteen_paging_nav();
wp_reset_postdata();
?>

OR
D ispl a y : T e m pl a t e s

Using the plugin Grid FX
Here’s the Page with Grid X plugin

Demo
Resources

Custom Post Type UI
Custom Sidebars
Plugins

Grid FX
Taxonomy List Widget
Post Types Order
Regenerate Thumbnails
Resources

U r b a n D icti o n a r y :

You can find anything on the Internet if you are willing
to look for it long enough.

Weitere ähnliche Inhalte

Was ist angesagt?

Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With BloggingTakatsugu Shigeta
 
Best practices for crafting high quality PHP apps (php[world] 2019)
Best practices for crafting high quality PHP apps (php[world] 2019)Best practices for crafting high quality PHP apps (php[world] 2019)
Best practices for crafting high quality PHP apps (php[world] 2019)James Titcumb
 
عرض حول وردبريس
عرض حول وردبريسعرض حول وردبريس
عرض حول وردبريسMohammed SAHLI
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - phpHung-yu Lin
 
HTML::FormHandler
HTML::FormHandlerHTML::FormHandler
HTML::FormHandlerbbeeley
 
Using php to design a guestbook website tutorial
Using php to design a guestbook website tutorialUsing php to design a guestbook website tutorial
Using php to design a guestbook website tutorialphillyquin
 
Drupal Form API 101 (PHP) - DrupalCamp LA 2012
Drupal Form API 101 (PHP) - DrupalCamp LA 2012Drupal Form API 101 (PHP) - DrupalCamp LA 2012
Drupal Form API 101 (PHP) - DrupalCamp LA 2012Chris Charlton
 
In some simple steps, your site can stand out from the rest. Here's how...
In some simple steps, your site can stand out from the rest. Here's how... In some simple steps, your site can stand out from the rest. Here's how...
In some simple steps, your site can stand out from the rest. Here's how... British Council
 

Was ist angesagt? (11)

Actions filters
Actions filtersActions filters
Actions filters
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With Blogging
 
Changing Template Engine
Changing Template EngineChanging Template Engine
Changing Template Engine
 
Best practices for crafting high quality PHP apps (php[world] 2019)
Best practices for crafting high quality PHP apps (php[world] 2019)Best practices for crafting high quality PHP apps (php[world] 2019)
Best practices for crafting high quality PHP apps (php[world] 2019)
 
عرض حول وردبريس
عرض حول وردبريسعرض حول وردبريس
عرض حول وردبريس
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
 
HTML::FormHandler
HTML::FormHandlerHTML::FormHandler
HTML::FormHandler
 
Web development
Web developmentWeb development
Web development
 
Using php to design a guestbook website tutorial
Using php to design a guestbook website tutorialUsing php to design a guestbook website tutorial
Using php to design a guestbook website tutorial
 
Drupal Form API 101 (PHP) - DrupalCamp LA 2012
Drupal Form API 101 (PHP) - DrupalCamp LA 2012Drupal Form API 101 (PHP) - DrupalCamp LA 2012
Drupal Form API 101 (PHP) - DrupalCamp LA 2012
 
In some simple steps, your site can stand out from the rest. Here's how...
In some simple steps, your site can stand out from the rest. Here's how... In some simple steps, your site can stand out from the rest. Here's how...
In some simple steps, your site can stand out from the rest. Here's how...
 

Andere mochten auch

Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateLaura Scott
 
Gravityforms
GravityformsGravityforms
GravityformsPhu Tran
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisIan Macali
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) ThemingPINGV
 
Web Fonts: Why Bother?
Web Fonts: Why Bother?Web Fonts: Why Bother?
Web Fonts: Why Bother?Greg Veen
 
Create Custom Post Type Plugin
Create Custom Post Type PluginCreate Custom Post Type Plugin
Create Custom Post Type PluginJan Wilson
 
MIWheat AR 2014
MIWheat AR 2014MIWheat AR 2014
MIWheat AR 2014Jan Wilson
 
잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기형우 안
 
Bootstrap 3
Bootstrap 3Bootstrap 3
Bootstrap 3Lanh Le
 

Andere mochten auch (12)

Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb update
 
Gravityforms
GravityformsGravityforms
Gravityforms
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) Theming
 
Theme Development from the Coding End
Theme Development from the Coding EndTheme Development from the Coding End
Theme Development from the Coding End
 
Web Fonts: Why Bother?
Web Fonts: Why Bother?Web Fonts: Why Bother?
Web Fonts: Why Bother?
 
Create Custom Post Type Plugin
Create Custom Post Type PluginCreate Custom Post Type Plugin
Create Custom Post Type Plugin
 
MIWheat AR 2014
MIWheat AR 2014MIWheat AR 2014
MIWheat AR 2014
 
잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기
 
Textorize
TextorizeTextorize
Textorize
 
Bootstrap 3
Bootstrap 3Bootstrap 3
Bootstrap 3
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 

Ähnlich wie Custom Post Type - Create and Display

How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress PluginAndy Stratton
 
Various Ways of Using WordPress
Various Ways of Using WordPressVarious Ways of Using WordPress
Various Ways of Using WordPressNick La
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPressNile Flores
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...LinnAlexandra
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Ian Wilson
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroChristopher Pecoraro
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress developmentSteve Mortiboy
 
Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015topher1kenobe
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme EnlightenmentAmanda Giles
 
Child Themes (WordCamp Dublin 2017) with notes
Child Themes (WordCamp Dublin 2017) with notesChild Themes (WordCamp Dublin 2017) with notes
Child Themes (WordCamp Dublin 2017) with notesDamien Carbery
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentSitdhibong Laokok
 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalChandra Prakash Thapa
 
oop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comoop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comtutorialsruby
 
oop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comoop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comtutorialsruby
 
Oop in php_tutorial_for_killerphp.com
Oop in php_tutorial_for_killerphp.comOop in php_tutorial_for_killerphp.com
Oop in php_tutorial_for_killerphp.comayandoesnotemail
 
Streamlining Your Template Structures When Building Themes
Streamlining Your Template Structures When Building ThemesStreamlining Your Template Structures When Building Themes
Streamlining Your Template Structures When Building ThemesCameron Jones
 

Ähnlich wie Custom Post Type - Create and Display (20)

How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
Various Ways of Using WordPress
Various Ways of Using WordPressVarious Ways of Using WordPress
Various Ways of Using WordPress
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPress
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
Child Themes (WordCamp Dublin 2017) with notes
Child Themes (WordCamp Dublin 2017) with notesChild Themes (WordCamp Dublin 2017) with notes
Child Themes (WordCamp Dublin 2017) with notes
 
Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme Development
 
09 Oo Php Register
09 Oo Php Register09 Oo Php Register
09 Oo Php Register
 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
 
oop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comoop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.com
 
oop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.comoop_in_php_tutorial_for_killerphp.com
oop_in_php_tutorial_for_killerphp.com
 
Oop in php_tutorial_for_killerphp.com
Oop in php_tutorial_for_killerphp.comOop in php_tutorial_for_killerphp.com
Oop in php_tutorial_for_killerphp.com
 
Oop in php tutorial
Oop in php tutorialOop in php tutorial
Oop in php tutorial
 
Streamlining Your Template Structures When Building Themes
Streamlining Your Template Structures When Building ThemesStreamlining Your Template Structures When Building Themes
Streamlining Your Template Structures When Building Themes
 

Mehr von Jan Wilson

Canzonetta Black and White
Canzonetta Black and WhiteCanzonetta Black and White
Canzonetta Black and WhiteJan Wilson
 
Cazonetta Contact Sheet Color
Cazonetta Contact Sheet ColorCazonetta Contact Sheet Color
Cazonetta Contact Sheet ColorJan Wilson
 
Contact sheet-wallace-bowl-3
Contact sheet-wallace-bowl-3Contact sheet-wallace-bowl-3
Contact sheet-wallace-bowl-3Jan Wilson
 
Contact sheet-wallace-bowl-2
Contact sheet-wallace-bowl-2Contact sheet-wallace-bowl-2
Contact sheet-wallace-bowl-2Jan Wilson
 
Contactsheet Wallace Bowl 1
Contactsheet Wallace Bowl 1Contactsheet Wallace Bowl 1
Contactsheet Wallace Bowl 1Jan Wilson
 
Contactsheet canz-bw
Contactsheet canz-bwContactsheet canz-bw
Contactsheet canz-bwJan Wilson
 
Canz contact-sheet-color
Canz contact-sheet-colorCanz contact-sheet-color
Canz contact-sheet-colorJan Wilson
 
My favorite word press plugins 2016
My favorite word press plugins  2016My favorite word press plugins  2016
My favorite word press plugins 2016Jan Wilson
 
Webfonts and Web Typography
Webfonts and Web TypographyWebfonts and Web Typography
Webfonts and Web TypographyJan Wilson
 

Mehr von Jan Wilson (10)

Canzonetta Black and White
Canzonetta Black and WhiteCanzonetta Black and White
Canzonetta Black and White
 
Cazonetta Contact Sheet Color
Cazonetta Contact Sheet ColorCazonetta Contact Sheet Color
Cazonetta Contact Sheet Color
 
Contact sheet-wallace-bowl-3
Contact sheet-wallace-bowl-3Contact sheet-wallace-bowl-3
Contact sheet-wallace-bowl-3
 
Contact sheet-wallace-bowl-2
Contact sheet-wallace-bowl-2Contact sheet-wallace-bowl-2
Contact sheet-wallace-bowl-2
 
Contactsheet Wallace Bowl 1
Contactsheet Wallace Bowl 1Contactsheet Wallace Bowl 1
Contactsheet Wallace Bowl 1
 
Contactsheet canz-bw
Contactsheet canz-bwContactsheet canz-bw
Contactsheet canz-bw
 
Colleen plumb
Colleen plumbColleen plumb
Colleen plumb
 
Canz contact-sheet-color
Canz contact-sheet-colorCanz contact-sheet-color
Canz contact-sheet-color
 
My favorite word press plugins 2016
My favorite word press plugins  2016My favorite word press plugins  2016
My favorite word press plugins 2016
 
Webfonts and Web Typography
Webfonts and Web TypographyWebfonts and Web Typography
Webfonts and Web Typography
 

Kürzlich hochgeladen

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 

Custom Post Type - Create and Display

  • 2. Welcome to my WordPress Lab. This is where I test WP stuff. *** Today we are going to create a Custom Post Type called Portfolio.
  • 3.
  • 4. If I have to write more than 4 lines of code, my head explodes
  • 6. C r e at e D i s p l ay Custom Post Type called Portfolio
  • 7. Here’s what it will look like Demo
  • 9. c r e a t e : P o r t f o li o Download Install Activate And here it is Add New
  • 10. c r e a t e : P o r t f o li o portfolio Portfolio
  • 11. c r e a t e : P o r t f o li o Advanced Options Change to True Scroll down to continue
  • 12. c r e a t e : P o r t f o li o
  • 13. c r e a t e : P o r t f o li o Next: Create a Taxonomy work_type Work Type
  • 14. c r e a t e : P o r t f o li o Associate Taxonomy with Portfolio
  • 15. c r e a t e : P o r t f o li o
  • 16. Show the posts you have created Demo
  • 17. The first time = 404 Settings>Permalinks and then update your present permalink structure by just clicking on the Save Changes button
  • 19. CPT : What is it?
  • 20. It’s not a post. But it acts like a post  It displays content on a Single post page  It can display content on an Archive page It’s not a page. But it acts like a page  It’s not heirarchical  You can assign it a page template  Normally, it can’t access categories that were created by the Post
  • 21. D ispl a y : T e m pl a t e s single.php Start with 3 exisiting files archive.php taxonomy.php
  • 22. D ispl a y : T e m pl a t e s single-portfolio.php Add a slug to the name archive-portfolio.php taxonomy-work_type.php
  • 23. See, it really works Demo
  • 24. th e m a g ic o f : Template Hierarchy a r chi v e p o st : si n g l e p o st : T a x o n o m y p o st : archive-portfolio.php single-portfolio.php taxonomy-work_type-logo.php archive.php single.php taxonomy-work_type.php index.php index.php taxonomy.php archive.php index.php
  • 25. SoWhy? To make your CPT posts look different from your single and archive posts that appear in your blog.
  • 26. D ispl a y : M o di f y th e t e m pl a t e taxonomy-work_type.php Page Title Thumbnail Post Title
  • 27. get_header(); ?> <section id=”primary” class=”content-area”> <div id=”content” class=”site-content” role=”main”> the loop <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post();?> <?php endwhile; twentyfourteen_paging_nav(); else : get_template_part( ‘content’, ‘none’ ); endif; ?> </div><!-- #content --> </section><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
  • 28. <?php if ( have_posts() ) : ?> <h1 class=”tax-title”><span>Work Type: </span> Page Title <?php $term_list = wp_get_post_terms($post->ID, ‘work_type’, array(“fields” => “names”)); $x = $term_list[0]; echo “$x”; ?> </h1> <?php while ( have_posts() ) : the_post();?> <div class=”grid”> Thumbnail Post Title <?php echo the_post_thumbnail(‘portfolio-thumb’); ?> <h4><a href=”<?php the_permalink(); ?>”> <?php the_title(); ?></a></h4> </div> <?php endwhile; twentyfourteen_paging_nav(); else : get_template_part( ‘content’, ‘none’ ); endif; ?>
  • 29. D ispl a y : m o di f y th e T e m pl a t e s https://codex.wordpress.org/ the_post_thumbnail(); // without parameter -> ‘post-thumbnail’ the_post_thumbnail(‘thumbnail’); // Thumbnail (default 150px x 150px max) the_post_thumbnail(‘medium’); // Medium resolution (default 300px x 300px max) the_post_thumbnail(‘large’); // Large resolution (default 640px x 640px max) the_post_thumbnail(‘full’); // Full resolution (original size uploaded) functions.php //Enable support for Post Thumbnails add_image_size( ‘portfolio-thumb’, 250, 250, true );
  • 30. More Display Fun CSS and the Body Class Thank you Becky Davis
  • 31. D ispl a y : C S S a n d B o d y cl a ss H1.page-title
  • 32. D ispl a y : C S S a n d B o d y cl a ss Use chrome inspector tool to find body class class = .post-type-archive-portfolio
  • 33. D ispl a y : C S S a n d B o d y cl a ss .post-type-archive-portfolio #primary h1.entry-title { font-weight:700; font-size:15px; letter-spacing: .15em; border: 1px #ccc dotted; padding: 20px; }
  • 34. Sidebar Navigation Shows links to Work Type Terms
  • 35. D ispl a y : sid e b a r  Custom Sidebars  Taxonomy* List Widget 2 Plugins *Posts use Categories // Custom Post Types use Taxonomy/Terms
  • 36. D ispl a y : S id e b a r Custom Sidebars Taxonomy List Widget Work Type Work Type
  • 37. Let’s see the sidebar in action Demo
  • 38. Another way to Display: Page Template! bye bye archive-portfolio.php
  • 39. Why a Page?  More control with design  Easier to add to a menu  Easier to add custom sidebars
  • 40. D ispl a y : T e m pl a t e s / P AGE Look Familiar? Duplic ate: page.php Rename: page-portfolio.php /* Template Name: Portfolio Page*/ Op en an d Add:
  • 41. D ispl a y : T e m pl a t e s / P AGE
  • 42. D ispl a y : T e m pl a t e s / P a g e Add php code to the template Use a Plugin: Grid FX <?php $args = array( ‘post_type’ => ‘portfolio’, ‘posts_per_page’ => 10 ); $loop = new WP_Query($args); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); get_template_part( ‘content’, get_post_format() ); endwhile; twentyfourteen_paging_nav(); wp_reset_postdata(); ?> OR
  • 43. D ispl a y : T e m pl a t e s Using the plugin Grid FX
  • 44. Here’s the Page with Grid X plugin Demo
  • 45.
  • 46. Resources Custom Post Type UI Custom Sidebars Plugins Grid FX Taxonomy List Widget Post Types Order Regenerate Thumbnails
  • 47. Resources U r b a n D icti o n a r y : You can find anything on the Internet if you are willing to look for it long enough.