SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Coolfields Consulting www.coolfields.co.uk
@coolfields
Simple Usability Improvements
for your WordPress Theme
Graham Armfield
graham.armfield@coolfields.co.uk
@coolfields
What I‟m Going to Cover
Suggested tweaks to improve usability
• Helping visitors find what they‟re looking for more easily.
Including
• Updates to theme files for search, blog pages, archive
pages, „landing‟ pages, „read more‟ links
• Using plugins to improve search results and pagination.
2
IMPROVING SEARCH
RESULTS DISPLAY
Giving visitors feedback about the
search they just did
3
Improving Search Results Display
Which is more informative?
4
TwentyEleven
Theme
Bespoke Theme
Improving Search Results Display
The code:
<h1>Search Results for: '<?php the_search_query(); ?>'</h1>
<p>You searched for
<strong>'<?php the_search_query(); ?>'</strong>
and the search returned
<?php echo $wp_query->found_posts; ?> items. Here are the
results:</p>
5
BETTER SEARCH RESULTS
Beyond the default WordPress Search
6
Better Search Results
WordPress Search Functionality
• Powerful search capability
• Built-in
• Dynamic
But, it does have limitations:
• Search results are ordered newest first – no assessment of
priority.
• There is no indication of the use of the search terms.
7
Better Search Results
Relevanssi plugin
http://wordpress.org/plugins/relevanssi/
• Results order based on relevance
• And/or search with multiple search words
• Fuzzy matching
• Customised excerpts to show use of search terms
• Minimum search word length
• Logging searches
• Compatible with custom post types
• Etc
8
Better Search Results
Relevanssi settings
9
Better Search Results
Relevanssi settings
10
Better Search Results
Customised excerpts highlight use of search terms
11
CUSTOMISING POST TYPE
DISPLAY
Because not all post types are the same
12
Customising post type display
Useful for:
• Archive page – by date, by category
• Search results page
Especially where you have many different post types – eg
Events, Articles, Reviews, etc
13
Customising post type display
14
This is an
article
This is an
event
Customising post type display
Let‟s create a function…
getPostTypeAtts($postType) {
switch ($postType) {
case 'page' :
$str = 'Page';
break;
case 'post' :
$str = 'News Item';
break;
case 'event' :
$str = 'Event';
break;
}
return array($str);
}
15
Customising post type display
In search.php, archive.php
<?php
while (have_posts()) : the_post();
$postTypeAtts = getPostTypeAtts(get_post_type());
$typeName = ' ('.$postTypeAtts[0].')';
?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); echo $typeName; ?></a></h2>
16
Customising post type display
17
Client chose not to have post type for
pages.
Customising post type display
Further customisations:
• Showing a published date, author, etc
• Customising the Read More link
• Etc
18
Customising post type display
getPostTypeAtts($postType) {
switch ($postType) {
case 'post' :
$str = 'News Item';
$showDate = true;
$readMore = 'Read the full news item';
break;
case 'job' :
$str = 'Job';
$showDate = false;
$readMore = 'Read more about the job';
break;
...
}
return array($str, $showDate, $readMore);
}
19
Customising post type display
In search.php, archive.php
<?php
while (have_posts()) : the_post();
$postTypeAtts = getPostTypeAtts(get_post_type());
$typeName = ' ('.$postTypeAtts[0].')';
?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); echo $typeName; ?></a></h2>
<?php if ($postTypeAtts[1]) { ?>
<p>Published: <?php the_time('M jS, Y'); </p> ?>
<?php }
the_excerpt(); ?>
<p><a href="<?php the_permalink() ?>"><?php the_title();
echo ': '. $postTypeAtts[2].' &raquo;' ?></a></p>
20
Customising post types
21
PRETTY PAGINATION
Helping visitors move around lists of
posts and search results.
22
Pretty pagination
We‟re all familiar with this:
Achieved using previous_posts_link() and next_posts_link()
This might be OK for site with not many posts, but what if you‟ve got
loads?
23
Pretty pagination
Might this work better?
Now your visitors have a much better idea of how many posts there
are. And they can quickly re-find one later.
24
Pretty pagination
Plugins available to do this:
• wp-pagenavi
• wp-paginate
But you do need to edit theme files to use them.
Because of customisation requirements I decided to build
my own functionality.
25
Pretty pagination
In WordPress, the common queries are paged by default – for
example:
• Blog index page
• Archive pages – categories, tags, etc
• Search results
The number of posts shown on each page is set in admin
settings. (But can be overridden by use of the
pre_get_posts hook.)
Custom queries using WP_Query are not paged by default but
paging can be induced by use of posts_per_page and
paged in query arguments.
26
Pretty pagination
Within each query there are two useful values that we can
use to help create the new style paging.
get_query_var('paged')
• Tells us which page of results we‟re on.
$wp_query -> max_num_pages
• Gives the total number of pages required to show all
results from the query.
• Works with default queries and with custom queries.
27
Pretty pagination
We‟ll need some code in the loop, and a function to
actually create the HTML for the new-style paging links.
Get the values at the start of the loop for use later
if (have_posts()) :
$paged = (get_query_var('paged')) ?
get_query_var('paged') : 1;
$pageMax = $wp_query -> max_num_pages;
while (have_posts()) : the_post();
28
Note that get_query_var('paged') is not set on first results
page so use this ternary operator to force value of $paged
to 1 if it‟s not set.
Pretty pagination
At the point you want the paging links to appear call a new
function:
<?php
endwhile; // endwhile for the loop or query
// If more than one page show links to others
if ($pageMax > 1) {
echo '<h3>Other Blog Entries</h3>';
echo doPaging($wp_query, $paged);
}
?>
<?php else : ?>
29
Pretty pagination
And the function – part 1:
function doPaging($myQuery, $paged) {
$str = '<ul class="paging">';
// Previous link? Yes if we're not on page 1
if ($paged > 1) {
$str .= '<li><a href="?paged='.($paged-1).'">&laquo;
Newer Posts</a></li>';
}
...
30
Pretty pagination
The doPaging function – part 2:
...
for($i=1; $i<=$myQuery->max_num_pages; $i++){
// Check if we're on that page
if ($paged==$i) {
// we are, so no link
$str .= '<li class="this-page"><span class=“srdr">Page
</span>'.$i.'</li>';
} else {
// put out the link
$str .= '<li><a href="?paged=' . $i.'"><span
class=“srdr">Page </span>'.$i.'</a></li>';
}
}
...
31
Pretty pagination
The doPaging function – part 3:
...
// Older posts link? Yes if we're not on last page
if ($paged < $myQuery->max_num_pages) {
$str .= '<li><a href="?paged='.($paged+1).'">Older
Posts &raquo;</a></li>';
}
$str .= '</ul>';
return $str;
}
32
Pretty pagination
Possible Enhancements:
• Customisation of text strings – eg “Next” and “Previous”
where custom post types or custom queries are used – the
results may not all be in chronological order.
• Amendments to function call to cater for paging on search
results – the required URLs for search results pages are in a
different format.
• Catering for sites with many, many pages of posts:
33
Summary
We‟ve seen just a few small enhancements that can be made to our
sites that can improve the visitors‟ experience.
There are others:
• Keeping the search query in the search box when showing results.
• Secondary navigation for child and sibling pages – not just relying on
dropdown menus.
34
Thanks for listening –
any (more) questions?
graham.armfield@coolfields.co.uk
@coolfields
35

Weitere ähnliche Inhalte

Was ist angesagt?

Haml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web DevelopmentHaml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web Developmentjeremyw
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress PluginAndy Stratton
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Storiesrahoulb
 
WordPress 15th Meetup - Build a Theme
WordPress 15th Meetup - Build a ThemeWordPress 15th Meetup - Build a Theme
WordPress 15th Meetup - Build a ThemeFadi Nicolas Zahhar
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Mike Schinkel
 
Telling Stories With RSpec
Telling Stories With RSpecTelling Stories With RSpec
Telling Stories With RSpecrahoulb
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWP Engine UK
 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - LondonMarek Sotak
 
Performance Tips In Rails Development
Performance Tips In Rails DevelopmentPerformance Tips In Rails Development
Performance Tips In Rails Developmentqtlove
 
Enter the app era with ruby on rails
Enter the app era with ruby on railsEnter the app era with ruby on rails
Enter the app era with ruby on railsMatteo Collina
 
Supercharged HTML & CSS
Supercharged HTML & CSSSupercharged HTML & CSS
Supercharged HTML & CSSMax Kraszewski
 
i18n for Plugin and Theme Developers, WordCamp Milano 2016
i18n for Plugin and Theme Developers, WordCamp Milano 2016i18n for Plugin and Theme Developers, WordCamp Milano 2016
i18n for Plugin and Theme Developers, WordCamp Milano 2016Sergey Biryukov
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With BloggingTakatsugu Shigeta
 
PHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the GoodPHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the GoodJeremy Kendall
 
HTML5 workshop, forms
HTML5 workshop, formsHTML5 workshop, forms
HTML5 workshop, formsRobert Nyman
 

Was ist angesagt? (20)

Haml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web DevelopmentHaml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web Development
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
20110820 header new style
20110820 header new style20110820 header new style
20110820 header new style
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Stories
 
Qpsmtpd
QpsmtpdQpsmtpd
Qpsmtpd
 
WordPress 15th Meetup - Build a Theme
WordPress 15th Meetup - Build a ThemeWordPress 15th Meetup - Build a Theme
WordPress 15th Meetup - Build a Theme
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
 
Telling Stories With RSpec
Telling Stories With RSpecTelling Stories With RSpec
Telling Stories With RSpec
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - London
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
 
Performance Tips In Rails Development
Performance Tips In Rails DevelopmentPerformance Tips In Rails Development
Performance Tips In Rails Development
 
Seo hints
Seo hintsSeo hints
Seo hints
 
Enter the app era with ruby on rails
Enter the app era with ruby on railsEnter the app era with ruby on rails
Enter the app era with ruby on rails
 
Supercharged HTML & CSS
Supercharged HTML & CSSSupercharged HTML & CSS
Supercharged HTML & CSS
 
i18n for Plugin and Theme Developers, WordCamp Milano 2016
i18n for Plugin and Theme Developers, WordCamp Milano 2016i18n for Plugin and Theme Developers, WordCamp Milano 2016
i18n for Plugin and Theme Developers, WordCamp Milano 2016
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With Blogging
 
PHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the GoodPHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the Good
 
HTML5 workshop, forms
HTML5 workshop, formsHTML5 workshop, forms
HTML5 workshop, forms
 
Changing Template Engine
Changing Template EngineChanging Template Engine
Changing Template Engine
 

Ähnlich wie Simple Usability Tweaks for Your WordPress Theme

The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme EnlightenmentAmanda Giles
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress WebsitesKyle Cearley
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPressNile Flores
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress sitereferences
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
 
Various Ways of Using WordPress
Various Ways of Using WordPressVarious Ways of Using WordPress
Various Ways of Using WordPressNick La
 
WordPress Theme Development: Part 2
WordPress Theme Development: Part 2WordPress Theme Development: Part 2
WordPress Theme Development: Part 2Josh Lee
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018Adam Tomat
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Adam Tomat
 
Building a Portfolio With Custom Post Types
Building a Portfolio With Custom Post TypesBuilding a Portfolio With Custom Post Types
Building a Portfolio With Custom Post TypesAlex Blackie
 
Can WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noCan WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noMorten Rand-Hendriksen
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction DjangoWade Austin
 
Custom Post Type - Create and Display
Custom Post Type - Create and DisplayCustom Post Type - Create and Display
Custom Post Type - Create and DisplayJan Wilson
 
Custom Post Types and Meta Fields
Custom Post Types and Meta FieldsCustom Post Types and Meta Fields
Custom Post Types and Meta FieldsLiton Arefin
 
WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...Denise Williams
 
WordPress and PHP - It Takes One to Know One
WordPress and PHP - It Takes One to Know OneWordPress and PHP - It Takes One to Know One
WordPress and PHP - It Takes One to Know OneLorelle VanFossen
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Djangofool2nd
 

Ähnlich wie Simple Usability Tweaks for Your WordPress Theme (20)

The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPress
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Various Ways of Using WordPress
Various Ways of Using WordPressVarious Ways of Using WordPress
Various Ways of Using WordPress
 
WordPress Theme Development: Part 2
WordPress Theme Development: Part 2WordPress Theme Development: Part 2
WordPress Theme Development: Part 2
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019
 
Building a Portfolio With Custom Post Types
Building a Portfolio With Custom Post TypesBuilding a Portfolio With Custom Post Types
Building a Portfolio With Custom Post Types
 
Can WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noCan WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.no
 
Django
DjangoDjango
Django
 
Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
Custom Post Type - Create and Display
Custom Post Type - Create and DisplayCustom Post Type - Create and Display
Custom Post Type - Create and Display
 
Custom Post Types and Meta Fields
Custom Post Types and Meta FieldsCustom Post Types and Meta Fields
Custom Post Types and Meta Fields
 
WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...
 
WordPress and PHP - It Takes One to Know One
WordPress and PHP - It Takes One to Know OneWordPress and PHP - It Takes One to Know One
WordPress and PHP - It Takes One to Know One
 
Victoria wordpress
Victoria wordpressVictoria wordpress
Victoria wordpress
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
 

Mehr von Graham Armfield

Useful Accessibility Tools Version 3 - Jul 2021
Useful Accessibility Tools Version 3 - Jul 2021Useful Accessibility Tools Version 3 - Jul 2021
Useful Accessibility Tools Version 3 - Jul 2021Graham Armfield
 
So how do i know if my wordpress website is accessible - WordPress Accessibil...
So how do i know if my wordpress website is accessible - WordPress Accessibil...So how do i know if my wordpress website is accessible - WordPress Accessibil...
So how do i know if my wordpress website is accessible - WordPress Accessibil...Graham Armfield
 
Useful Accessibility Tools - WordCamp Brighton
Useful Accessibility Tools - WordCamp BrightonUseful Accessibility Tools - WordCamp Brighton
Useful Accessibility Tools - WordCamp BrightonGraham Armfield
 
Accessibility Hacks Version 2
Accessibility Hacks Version 2Accessibility Hacks Version 2
Accessibility Hacks Version 2Graham Armfield
 
Accessibility Hacks version 2
Accessibility Hacks version 2Accessibility Hacks version 2
Accessibility Hacks version 2Graham Armfield
 
Useful Accessibility Tools - WP Pompey April 2019
Useful Accessibility Tools - WP Pompey April 2019Useful Accessibility Tools - WP Pompey April 2019
Useful Accessibility Tools - WP Pompey April 2019Graham Armfield
 
How to Build an Accessible WordPress Theme
How to Build an Accessible WordPress ThemeHow to Build an Accessible WordPress Theme
How to Build an Accessible WordPress ThemeGraham Armfield
 
Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018Graham Armfield
 
Useful Accessibility Tools
Useful Accessibility ToolsUseful Accessibility Tools
Useful Accessibility ToolsGraham Armfield
 
Assistive technology Demo WordCamp Bristol
Assistive technology Demo WordCamp BristolAssistive technology Demo WordCamp Bristol
Assistive technology Demo WordCamp BristolGraham Armfield
 
Designing for Accessibility - WordCamp London 2017
Designing for Accessibility - WordCamp London 2017Designing for Accessibility - WordCamp London 2017
Designing for Accessibility - WordCamp London 2017Graham Armfield
 
Designing for Accessibility - Front End North - September 2016
Designing for Accessibility - Front End North - September 2016Designing for Accessibility - Front End North - September 2016
Designing for Accessibility - Front End North - September 2016Graham Armfield
 
Obscure Wordpress Functions That Are Actually Quite Useful
Obscure Wordpress Functions That Are Actually Quite UsefulObscure Wordpress Functions That Are Actually Quite Useful
Obscure Wordpress Functions That Are Actually Quite UsefulGraham Armfield
 
Themes Plugins and Accessibility - WordCamp London March 2015
Themes Plugins and Accessibility - WordCamp London March 2015Themes Plugins and Accessibility - WordCamp London March 2015
Themes Plugins and Accessibility - WordCamp London March 2015Graham Armfield
 
Can WordPress help make the web more accessible - eaccess15 - Feb 2015
Can WordPress help make the web more accessible - eaccess15 - Feb 2015Can WordPress help make the web more accessible - eaccess15 - Feb 2015
Can WordPress help make the web more accessible - eaccess15 - Feb 2015Graham Armfield
 
Themes, Plugins and Accessibility
Themes, Plugins and AccessibilityThemes, Plugins and Accessibility
Themes, Plugins and AccessibilityGraham Armfield
 
Wordpress and Web Accessibility Wordcamp UK 2014
Wordpress and Web Accessibility Wordcamp UK 2014Wordpress and Web Accessibility Wordcamp UK 2014
Wordpress and Web Accessibility Wordcamp UK 2014Graham Armfield
 
So What is This Thing Called WordPress?
So What is This Thing Called WordPress?So What is This Thing Called WordPress?
So What is This Thing Called WordPress?Graham Armfield
 
So How Do I Know if My Website is Accessible?
So How Do I Know if My Website is Accessible?So How Do I Know if My Website is Accessible?
So How Do I Know if My Website is Accessible?Graham Armfield
 
Handling User Generated Content in WordPress
Handling User Generated Content in WordPressHandling User Generated Content in WordPress
Handling User Generated Content in WordPressGraham Armfield
 

Mehr von Graham Armfield (20)

Useful Accessibility Tools Version 3 - Jul 2021
Useful Accessibility Tools Version 3 - Jul 2021Useful Accessibility Tools Version 3 - Jul 2021
Useful Accessibility Tools Version 3 - Jul 2021
 
So how do i know if my wordpress website is accessible - WordPress Accessibil...
So how do i know if my wordpress website is accessible - WordPress Accessibil...So how do i know if my wordpress website is accessible - WordPress Accessibil...
So how do i know if my wordpress website is accessible - WordPress Accessibil...
 
Useful Accessibility Tools - WordCamp Brighton
Useful Accessibility Tools - WordCamp BrightonUseful Accessibility Tools - WordCamp Brighton
Useful Accessibility Tools - WordCamp Brighton
 
Accessibility Hacks Version 2
Accessibility Hacks Version 2Accessibility Hacks Version 2
Accessibility Hacks Version 2
 
Accessibility Hacks version 2
Accessibility Hacks version 2Accessibility Hacks version 2
Accessibility Hacks version 2
 
Useful Accessibility Tools - WP Pompey April 2019
Useful Accessibility Tools - WP Pompey April 2019Useful Accessibility Tools - WP Pompey April 2019
Useful Accessibility Tools - WP Pompey April 2019
 
How to Build an Accessible WordPress Theme
How to Build an Accessible WordPress ThemeHow to Build an Accessible WordPress Theme
How to Build an Accessible WordPress Theme
 
Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018
 
Useful Accessibility Tools
Useful Accessibility ToolsUseful Accessibility Tools
Useful Accessibility Tools
 
Assistive technology Demo WordCamp Bristol
Assistive technology Demo WordCamp BristolAssistive technology Demo WordCamp Bristol
Assistive technology Demo WordCamp Bristol
 
Designing for Accessibility - WordCamp London 2017
Designing for Accessibility - WordCamp London 2017Designing for Accessibility - WordCamp London 2017
Designing for Accessibility - WordCamp London 2017
 
Designing for Accessibility - Front End North - September 2016
Designing for Accessibility - Front End North - September 2016Designing for Accessibility - Front End North - September 2016
Designing for Accessibility - Front End North - September 2016
 
Obscure Wordpress Functions That Are Actually Quite Useful
Obscure Wordpress Functions That Are Actually Quite UsefulObscure Wordpress Functions That Are Actually Quite Useful
Obscure Wordpress Functions That Are Actually Quite Useful
 
Themes Plugins and Accessibility - WordCamp London March 2015
Themes Plugins and Accessibility - WordCamp London March 2015Themes Plugins and Accessibility - WordCamp London March 2015
Themes Plugins and Accessibility - WordCamp London March 2015
 
Can WordPress help make the web more accessible - eaccess15 - Feb 2015
Can WordPress help make the web more accessible - eaccess15 - Feb 2015Can WordPress help make the web more accessible - eaccess15 - Feb 2015
Can WordPress help make the web more accessible - eaccess15 - Feb 2015
 
Themes, Plugins and Accessibility
Themes, Plugins and AccessibilityThemes, Plugins and Accessibility
Themes, Plugins and Accessibility
 
Wordpress and Web Accessibility Wordcamp UK 2014
Wordpress and Web Accessibility Wordcamp UK 2014Wordpress and Web Accessibility Wordcamp UK 2014
Wordpress and Web Accessibility Wordcamp UK 2014
 
So What is This Thing Called WordPress?
So What is This Thing Called WordPress?So What is This Thing Called WordPress?
So What is This Thing Called WordPress?
 
So How Do I Know if My Website is Accessible?
So How Do I Know if My Website is Accessible?So How Do I Know if My Website is Accessible?
So How Do I Know if My Website is Accessible?
 
Handling User Generated Content in WordPress
Handling User Generated Content in WordPressHandling User Generated Content in WordPress
Handling User Generated Content in WordPress
 

Kürzlich hochgeladen

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
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
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
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
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
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
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
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
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 

Kürzlich hochgeladen (20)

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
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
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
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
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
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
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
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
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 

Simple Usability Tweaks for Your WordPress Theme

  • 1. Coolfields Consulting www.coolfields.co.uk @coolfields Simple Usability Improvements for your WordPress Theme Graham Armfield graham.armfield@coolfields.co.uk @coolfields
  • 2. What I‟m Going to Cover Suggested tweaks to improve usability • Helping visitors find what they‟re looking for more easily. Including • Updates to theme files for search, blog pages, archive pages, „landing‟ pages, „read more‟ links • Using plugins to improve search results and pagination. 2
  • 3. IMPROVING SEARCH RESULTS DISPLAY Giving visitors feedback about the search they just did 3
  • 4. Improving Search Results Display Which is more informative? 4 TwentyEleven Theme Bespoke Theme
  • 5. Improving Search Results Display The code: <h1>Search Results for: '<?php the_search_query(); ?>'</h1> <p>You searched for <strong>'<?php the_search_query(); ?>'</strong> and the search returned <?php echo $wp_query->found_posts; ?> items. Here are the results:</p> 5
  • 6. BETTER SEARCH RESULTS Beyond the default WordPress Search 6
  • 7. Better Search Results WordPress Search Functionality • Powerful search capability • Built-in • Dynamic But, it does have limitations: • Search results are ordered newest first – no assessment of priority. • There is no indication of the use of the search terms. 7
  • 8. Better Search Results Relevanssi plugin http://wordpress.org/plugins/relevanssi/ • Results order based on relevance • And/or search with multiple search words • Fuzzy matching • Customised excerpts to show use of search terms • Minimum search word length • Logging searches • Compatible with custom post types • Etc 8
  • 11. Better Search Results Customised excerpts highlight use of search terms 11
  • 12. CUSTOMISING POST TYPE DISPLAY Because not all post types are the same 12
  • 13. Customising post type display Useful for: • Archive page – by date, by category • Search results page Especially where you have many different post types – eg Events, Articles, Reviews, etc 13
  • 14. Customising post type display 14 This is an article This is an event
  • 15. Customising post type display Let‟s create a function… getPostTypeAtts($postType) { switch ($postType) { case 'page' : $str = 'Page'; break; case 'post' : $str = 'News Item'; break; case 'event' : $str = 'Event'; break; } return array($str); } 15
  • 16. Customising post type display In search.php, archive.php <?php while (have_posts()) : the_post(); $postTypeAtts = getPostTypeAtts(get_post_type()); $typeName = ' ('.$postTypeAtts[0].')'; ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark"> <?php the_title(); echo $typeName; ?></a></h2> 16
  • 17. Customising post type display 17 Client chose not to have post type for pages.
  • 18. Customising post type display Further customisations: • Showing a published date, author, etc • Customising the Read More link • Etc 18
  • 19. Customising post type display getPostTypeAtts($postType) { switch ($postType) { case 'post' : $str = 'News Item'; $showDate = true; $readMore = 'Read the full news item'; break; case 'job' : $str = 'Job'; $showDate = false; $readMore = 'Read more about the job'; break; ... } return array($str, $showDate, $readMore); } 19
  • 20. Customising post type display In search.php, archive.php <?php while (have_posts()) : the_post(); $postTypeAtts = getPostTypeAtts(get_post_type()); $typeName = ' ('.$postTypeAtts[0].')'; ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark"> <?php the_title(); echo $typeName; ?></a></h2> <?php if ($postTypeAtts[1]) { ?> <p>Published: <?php the_time('M jS, Y'); </p> ?> <?php } the_excerpt(); ?> <p><a href="<?php the_permalink() ?>"><?php the_title(); echo ': '. $postTypeAtts[2].' &raquo;' ?></a></p> 20
  • 22. PRETTY PAGINATION Helping visitors move around lists of posts and search results. 22
  • 23. Pretty pagination We‟re all familiar with this: Achieved using previous_posts_link() and next_posts_link() This might be OK for site with not many posts, but what if you‟ve got loads? 23
  • 24. Pretty pagination Might this work better? Now your visitors have a much better idea of how many posts there are. And they can quickly re-find one later. 24
  • 25. Pretty pagination Plugins available to do this: • wp-pagenavi • wp-paginate But you do need to edit theme files to use them. Because of customisation requirements I decided to build my own functionality. 25
  • 26. Pretty pagination In WordPress, the common queries are paged by default – for example: • Blog index page • Archive pages – categories, tags, etc • Search results The number of posts shown on each page is set in admin settings. (But can be overridden by use of the pre_get_posts hook.) Custom queries using WP_Query are not paged by default but paging can be induced by use of posts_per_page and paged in query arguments. 26
  • 27. Pretty pagination Within each query there are two useful values that we can use to help create the new style paging. get_query_var('paged') • Tells us which page of results we‟re on. $wp_query -> max_num_pages • Gives the total number of pages required to show all results from the query. • Works with default queries and with custom queries. 27
  • 28. Pretty pagination We‟ll need some code in the loop, and a function to actually create the HTML for the new-style paging links. Get the values at the start of the loop for use later if (have_posts()) : $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $pageMax = $wp_query -> max_num_pages; while (have_posts()) : the_post(); 28 Note that get_query_var('paged') is not set on first results page so use this ternary operator to force value of $paged to 1 if it‟s not set.
  • 29. Pretty pagination At the point you want the paging links to appear call a new function: <?php endwhile; // endwhile for the loop or query // If more than one page show links to others if ($pageMax > 1) { echo '<h3>Other Blog Entries</h3>'; echo doPaging($wp_query, $paged); } ?> <?php else : ?> 29
  • 30. Pretty pagination And the function – part 1: function doPaging($myQuery, $paged) { $str = '<ul class="paging">'; // Previous link? Yes if we're not on page 1 if ($paged > 1) { $str .= '<li><a href="?paged='.($paged-1).'">&laquo; Newer Posts</a></li>'; } ... 30
  • 31. Pretty pagination The doPaging function – part 2: ... for($i=1; $i<=$myQuery->max_num_pages; $i++){ // Check if we're on that page if ($paged==$i) { // we are, so no link $str .= '<li class="this-page"><span class=“srdr">Page </span>'.$i.'</li>'; } else { // put out the link $str .= '<li><a href="?paged=' . $i.'"><span class=“srdr">Page </span>'.$i.'</a></li>'; } } ... 31
  • 32. Pretty pagination The doPaging function – part 3: ... // Older posts link? Yes if we're not on last page if ($paged < $myQuery->max_num_pages) { $str .= '<li><a href="?paged='.($paged+1).'">Older Posts &raquo;</a></li>'; } $str .= '</ul>'; return $str; } 32
  • 33. Pretty pagination Possible Enhancements: • Customisation of text strings – eg “Next” and “Previous” where custom post types or custom queries are used – the results may not all be in chronological order. • Amendments to function call to cater for paging on search results – the required URLs for search results pages are in a different format. • Catering for sites with many, many pages of posts: 33
  • 34. Summary We‟ve seen just a few small enhancements that can be made to our sites that can improve the visitors‟ experience. There are others: • Keeping the search query in the search box when showing results. • Secondary navigation for child and sibling pages – not just relying on dropdown menus. 34
  • 35. Thanks for listening – any (more) questions? graham.armfield@coolfields.co.uk @coolfields 35