Content everywhere
TAMING YOUR CONTENT with CUSTOM POST TYPES o META FIELDS
@CAROLYNLYNZ WHO AM I? Z
2
SITE OWNER
Z WHO AM I? Z
3
MARKETER
Z WHO AM I? Z
4
OCCASIONAL FOOD BLOGGER
Z WHO AM I? Z
5
!=DESIGNERZ WHO AM I? Z
This will become apparent when you see shots of my site6
!=DEVELOPERZ WHO AM I? Z
This will become apparent when I talk about code (especially if youre a developer)7
==TINKERERZ WHO AM I? Z
IM HAPPY TO PLAY WITH CODE AND CROSS MY FINGERS IT DOESNT BREAK TOO MUCH8
Were going to look at one of my projects. Stuck in the Tree helps bingo players research new sites to play at before they sign up.
I started Stuck in the Tree a few years ago when I was working as an SEO to test theories and tinker with things.I now use it to test out marketing ideas and learn more about WordPress and PHP Ill take you from where I started to where custom fields etc has taken things
9
CUSTOM POST TYPES O FIELDSwatz dat den?
Out of the box WordPress has post and pages, you can extend it to have any number of custom post types10
CUSTOM POST TYPES O FIELDS
. Common examples would be book or movie databases, or products in an online shop. You can also create custom fields which you can see here being use for the product price, and rating. Potentially also the product description and the image. (Example Theme from https://woocommerce.com/storefront/)
11
CUSTOM POST TYPES O FIELDS
Most of the sections on Stuck in the Tree including are powered by WordPress Custom Post types behind the scenes. So a pretty conventional use in our bingo site reviews but also a little unusual to power some of our fun quizzes and our bingo cards. 12
START AS YOU MEAN TO GO ON
When youre working on a project there are two main approaches13
START AS YOU MEAN TO GO ONor LAUNCHQUICK ANDFIX IT LATER
We went chose to launch a minimum viable product and then do continual development. Otherwise the site would never have been launched. So weve learnt a lot and made a lot of changes along the way
14
TO PLUGINorNOT TO PLUGIN
Didnt need drag and drop for creating and managing post types taxonomies and fields
Wanted a bit of assistance with the meta boxes
Want to learn more / understand behind scenes15
NO PLUGINtoo hardcore
ADVANCED CUSTOM FIELDS PLUGINoverkill (for us)
CUSTOM META BOXES PLUGINand the shoe fits!
https://github.com/humanmade/Custom-Meta-Boxes
CUSTOM POST TYPES from the offBingo ReviewsTreehouse Blog
But few custom fieldsNone in the reviews
Whilte we use custom post types form the off, for the bingo reviews we use of custom fields to pull through key data onto archive pages, for example the value of the free bonus, site logo 19
THIS WAS OUR REVIEW owch my eyes!
But the reviews themselves were one very long block of text and html.
Load of html and layout stuff in the editorLong time to create a new reviewRisk of error highDesign / layout of reviews have to be altered one by one.
20
CREATING a custom post type
http://www.stuckinthetree.co.uk/dev-blog/getting-started-with-wordpress-custom-post-types-and-fields/https://codex.wordpress.org/Function_Reference/register_post_type
Standard WordPress method21
CREATING a custom taxonomy
Standard WordPress method
22
CREATING custom fields O meta boxes
Rather than using WordPress standard methods it uses the CMB plugins functions which are simplified23
DISPLAYING FIELD DATA
Standard WordPress method24
TAMINGourBINGO SITE REVIEWS
theADMIN MENU
ICONS
https://developer.wordpress.org/resource/dashicons
MENU POSITION
ADMIN MENU EDITOR PLUGINEasily order, hide, add new menu items & add icons to the menu.
https://wordpress.org/plugins/admin-menu-editor/
This plugin was a compromise as were not going to want to regularly update the admin menu we may look at doing this without a plugin in future but for now weve got other things to focus on.
29
TIDYING UPtheEDITOR
CUSTOM FIELDS what a mess
WHAT ABOUT all this stuff
AND all this stuff
UNCHECK in screen options pane
OR USE a few lines of codehides the fields it doesnt remove support for it.
But if other people are using the backend then it can be better to just hide them automatically with a few lines of code.
35
OR USE a few lines of codeYou can even make this only for non-admins
https://codex.wordpress.org/Function_Reference/remove_meta_box
Explain why used manage options rather than administrators.36
REMOVING the featured imageCant be removed as specified in codex
Various workaroundsWe use custom fields for our images so dont and wont use itWe removed support for it for this post type
37
REMOVING the featured imageSo we removed thumbnail support
Various workaroundsWe use custom fields for our images so dont and wont use itWe removed support for it for this post type
38
ORDERING METABOXES in editor$context$priorityadvanceddefaulthighlowcorenormaldefaulthighlowcoresidedefaulthighlowcore
Positions are relativeOnly 12 positionsIn case of tie is alphanumeric
Positioning is relativeOnly 12 real position optionsin the case of a tie it will go by the numbers and alphabetically - so consider this when naming your fields
So fine if you only have a few fields and no fields fro other pluginsPain if you have lots of fields and other plugins too
Can be changed by users who can switch between 1 and 2 column layout and drag and drop the metaboxes around.
39
DISPLAYING field helpers
BASIC 12 COLUMN GRID from this
BASIC 12 COLUMN GRID to this
42
LETS CLEAN IT UP SOME MORE
Setting the height of the editorSpecifying which quicktags we wantAnd removing the add media button43
CUSTOM FIELDS inside CUSTOM FIELDS
SO WHAT IF the bonus value changes?
http://www.stuckinthetree.co.uk/dev-blog/custom-fields-within-custom-fields-shortcodes/
45
CREATE O whitelist your shortcode
WRAP FIELDS with do_shortcodeE.g. in our single-bingo-sites.php
REGEX PARSES STRING O triggers shortcode
CROSS PROMOTION ADS
CROSS PROMOTION post type
50
CROSS PROMOTION post type
51
CROSS PROMOTION post type
52
CUSTOMISE your ALL POSTS SCREEN
BEFORE customisation
AFTER customisation
CAN HIDE COLUMNS with screen options
ADD COLUMN HEADINGS
http://www.stuckinthetree.co.uk/dev-blog/how-to-customise-the-all-posts-or-custom-post-type-screen-in-wordpress/
57
DISPLAYING THE CONTENT
MAKE YOUR COLUMNS SORTABLE
THE DASHBOARD
The first page youll see when you loginFor most people this just adds an extra step and they are not interested in this pageYou can expand the dashboard by making new Dashboard Widgets
60
THE DASHBOARD IS THE MOST USEFUL SCREEN IN THE WORDPRESS ADMINSaid No One Ever.
Change the landing page when you loginYou could show based on user roles so Admins can see one page and non-admins can be shown a different pageE.g. a content calendar, the All Posts page etc.61
HOW TO REDIRECT ON LOGINto post edit screen
WHAT ELSEcanCUSTOM POSTS / FIELDS DO?
The skys the limit really63
WE LIKE fun and games
We like creating interactive content and use custom posts types and fields to created them. 64
WE LIKE fun and games
Archive templateDisplaying custom postsEach with own post metahttp://www.stuckinthetree.co.uk/bake-off-bingo-generator/
For example bingo card generators are just an archive template displaying a custom posts each with their own post meta.65
THANK YOU VS @carolynlyn
P http://www.stuckinthetree.co.uk/dev-blog/
66