SlideShare ist ein Scribd-Unternehmen logo
1 von 63
Can WordPress
Really Do That?
- a case study of
vierderduer.no

Morten Rand-Hendriksen
morten@pinkandyellow.com | @mor10 |
designisphilosophy.com
www.designisphilosophy.co
m
www.lynda.com/mor10
Twitter: @mor10

Morten Rand-Hendriksen
morten@pinkandyellow.com | @mor10 |
designisphilosophy.com
A little history
and a lesson in Norwegian
= 5 kr ( roughly $1
                  )
Oh, and we want the site to
send SMS messages to the
applicants whenever their
application has been updated.

Can WordPress really do that?
A look behind the scenes
Don’t reinvent the wheel
Featured
image
Featured
image
Post title
Featured
image
Post title
Taxonomies
Featured
image
Post title
Taxonomies
Custom Fields
Featured
image
Post title
Taxonomies
Custom Fields
Based on Like
count
Featured
image
Post title
Taxonomies
Custom Fields
Based on Like
Based on
count
Publish Date
Dynamic content on single
         pages
Custom Post Types:

http://codex.wordpress.org/Function_Reference/re
                 gister_post_type
Custom Taxonomies:

http://codex.wordpress.org/Function_Reference/re
                 gister_taxonomy
Set a default taxonomy term
User Generated Posts
The Form Itself
Custom Index Pages
 for custom post types,
   custom taxonomies,
    and the front page
WordPress Template Hierarchy
http://codex.wordpress.org/Template_Hierar
                    chy
Custom Index Pages

             archive-$post_type.php
Custom Post Types:
             taxonomy-$taxonomy-
Custom Taxonomies:
Front Page: $term.php
             front-page.php
Custom Queries and Loops
FIRST
LOOP:
8 latest new
applications




SECOND
LOOP:
4 latest grants
FIRST
LOOP:
8 latest new
applications



SECOND
LOOP:
4 latest grants
granted
<?php get_template_part('indexBoxLoop'); ?>
<?php include('posttypes'); ?>
<?php get_template_part('indexBoxLoop'); ?>
Get the term list for an object

<?php
        echo get_the_term_list(
              $post->ID,
              '$term',
              '[before list]',
              '[between each item]',
              '[after list]' );
?>
Get the term list for an object

<?php
        echo get_the_term_list(
              $post->ID,
              'aktivitet',
              '',
              ' ',
              '' );
?>
Get the term list for an object

<?php
        echo "<ul>";
        echo get_the_term_list(
              $post->ID,
              'aktivitet',
              '<li>',
              '</li><li>',
              '</li>' );
        echo "</ul>";
?>
A Lesson Learned:

DON’T TRUST FACEBOOK!
≠ 1 like
= 1 like
or 1 share
or 1
comment
or 1 click
etc etc etc
Getting Facebook Like (etc)
             Numbers
    Facebook Query Language (FQL)
https://api.facebook.com/method/fql.query?query=select%20%
20like_count,%20total_count,%20share_count,%20click_count,
%20comment_count%20from%20link_stat%20where%20url='http://
www.wordcampvictoria.ca/'&format=xml
Getting Facebook Like (etc)
             Numbers
    Facebook Query Language (FQL)
https://api.facebook.com/method/fql.query?query=
select%20
%20like_count,
%20total_count,
%20share_count,
%20click_count,
%20comment_count
%20from%20link_stat%20where
%20url='http://www.wordcampvictoria.ca/'
&format=xml
Getting Facebook Like (etc)
             Numbers
    Facebook Query Language (FQL)
https://api.facebook.com/method/fql.query?query=select%20%
20like_count,%20total_count,%20share_count,%20click_count,
%20comment_count%20from%20link_stat%20where%20url='http://
www.wordcampvictoria.ca/'&format=xml
Parsing Facebook Like
              Numbers
<?php
$permalink = get_permalink( $post->ID );
$content =
file_get_contents("https://api.facebook.com/method/fql.que
ry?query=select%20total_count%20from%20link_stat%20where%2
0url='" . $permalink . "'&format=xml");
$element = new SimpleXmlElement($content);
$likes = $element->link_stat->total_count;

echo $likes;
?>
Computers are really good at
          math
Finding the percentage for
            completion
<?php
$earned = ($likes*5);
?>
<div class="earned">
  Earned: <?php echo $earned; ?>kr
</div><!-- .earned -->
Finding the percentage for
            completion
<?php
$kroner = ($likes*5);
if ($kroner <= 3000) {
  $earned = $kroner;
} else {
  $earned = 3000;
}
?>
<div class="earned">
  Earned: <?php echo $earned; ?>kr
</div><!-- .earned -->
Finding the percentage for
            completion
<?php
$kroner = ($likes*5);
if ($kroner <= 3000) {
  $earned = $kroner;
  $percent = (($likes*100)/600);
} else {
  $earned = 3000;
  $percent = 100;
}
?>
<div class="earned">
  <span style="width: <?php echo $percent; ?>%">
    Earned: <?php echo $earned; ?>kr
  </span>
</div><!-- .earned -->
Making the percentage graph
.earned {
       background-color: #dfe0e0;
       position: relative;
       height: 8px;
       margin-top: 15px;
       border-radius: 5px;
}
.earned span {
       background-color: #16bcee;
       position: absolute;
       height: 8px;
       text-indent: -9999px;
       border-radius: 5px;
}
What about this SMS thing?
Anything WordPress can do I
              can do too
                     In this case
<?php
add_action('publish_soknad', 'check_term_changes', 10, 2);
function check_term_changes($post_id, $post){
  $terms = wp_get_object_terms($post_id, $taxonomy);

 switch($term_id) {
   case $term_id == $status_terms['post_likes']:
   $sms_message = message;
   break;
 update_post_meta($post_id, '_prev_status', $term_id);
}
?>
Bonus 1
 Get (and fix) URL from a custom field
<?php
if ((get_post_meta($post->ID, 'website', true))) {
  $websiteURL = get_post_meta($post->ID, 'website', true);
  if (substr($websiteURL,0,7) != 'http://') {
    $websiteURL = 'http://' . $websiteURL;
  }
?>
<a href="<?php echo $websiteURL ?>“ title="Website">
  The Website
</a>
<?php } ?>
Bonus 2
      Automatic oEmbed of videos via
<?php
               custom field
if(get_post_meta($post->ID, 'video', true)) { ?>
  <div id="video">
    <?php
      $video = get_post_meta($post->ID, 'video', true);
      echo wp_oembed_get( $video );
    ?>
  </div>
<?php
}
?>
Questions?
come on, you know you got
‘em...
www.designisphilosophy.co
m
www.lynda.com/mor10
Twitter: @mor10

Morten Rand-Hendriksen
morten@pinkandyellow.com | @mor10 |
designisphilosophy.com

Weitere ähnliche Inhalte

Was ist angesagt?

WordPress Security - WordCamp Phoenix
WordPress Security - WordCamp PhoenixWordPress Security - WordCamp Phoenix
WordPress Security - WordCamp Phoenix
Mark Jaquith
 
Desenvolvimento web usando django
Desenvolvimento web usando djangoDesenvolvimento web usando django
Desenvolvimento web usando django
yurimalheiros
 
Redes sociais usando python
Redes sociais usando pythonRedes sociais usando python
Redes sociais usando python
yurimalheiros
 

Was ist angesagt? (19)

WordPress Security - WordCamp Phoenix
WordPress Security - WordCamp PhoenixWordPress Security - WordCamp Phoenix
WordPress Security - WordCamp Phoenix
 
Apostrophe
ApostropheApostrophe
Apostrophe
 
MIPS Merge Sort
MIPS Merge SortMIPS Merge Sort
MIPS Merge Sort
 
Wp query
Wp queryWp query
Wp query
 
16.mysql stored procedures in laravel
16.mysql stored procedures in laravel16.mysql stored procedures in laravel
16.mysql stored procedures in laravel
 
Desenvolvimento web usando django
Desenvolvimento web usando djangoDesenvolvimento web usando django
Desenvolvimento web usando django
 
Developing applications for performance
Developing applications for performanceDeveloping applications for performance
Developing applications for performance
 
Redes sociais usando python
Redes sociais usando pythonRedes sociais usando python
Redes sociais usando python
 
全裸でワンライナー(仮)
全裸でワンライナー(仮)全裸でワンライナー(仮)
全裸でワンライナー(仮)
 
Introtodatabase 1
Introtodatabase 1Introtodatabase 1
Introtodatabase 1
 
FVCP - Facebook , Twitter and Meetup API / Widgets
FVCP - Facebook , Twitter and Meetup API / WidgetsFVCP - Facebook , Twitter and Meetup API / Widgets
FVCP - Facebook , Twitter and Meetup API / Widgets
 
August 10th, 2009 Pete De Mulle Twitter
August 10th, 2009 Pete De Mulle TwitterAugust 10th, 2009 Pete De Mulle Twitter
August 10th, 2009 Pete De Mulle Twitter
 
Templates don’t need to break the browser by Nikolas Martens
Templates don’t need to break the browser by Nikolas Martens  Templates don’t need to break the browser by Nikolas Martens
Templates don’t need to break the browser by Nikolas Martens
 
Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017
Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017
Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017
 
Seasion5
Seasion5Seasion5
Seasion5
 
Session6
Session6Session6
Session6
 
PHP performance 101: so you need to use a database
PHP performance 101: so you need to use a databasePHP performance 101: so you need to use a database
PHP performance 101: so you need to use a database
 
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHPDifference between mysql_fetch_array and mysql_fetch_assoc in PHP
Difference between mysql_fetch_array and mysql_fetch_assoc in PHP
 
Hop ngu MIP
Hop ngu MIPHop ngu MIP
Hop ngu MIP
 

Andere mochten auch

Andere mochten auch (6)

Wp meetup custom post types
Wp meetup custom post typesWp meetup custom post types
Wp meetup custom post types
 
10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site
 
Your Blog is Boring and Your Photos Suck
Your Blog is Boring and Your Photos SuckYour Blog is Boring and Your Photos Suck
Your Blog is Boring and Your Photos Suck
 
Ethics and the Promise of Open Source
Ethics and the Promise of Open SourceEthics and the Promise of Open Source
Ethics and the Promise of Open Source
 
Responsive Images in the Real World - presented at JavaScript Open 2015
Responsive Images in the Real World - presented at JavaScript Open 2015Responsive Images in the Real World - presented at JavaScript Open 2015
Responsive Images in the Real World - presented at JavaScript Open 2015
 
Empathy and Acceptance in Design and Community
Empathy and Acceptance in Design and CommunityEmpathy and Acceptance in Design and Community
Empathy and Acceptance in Design and Community
 

Ähnlich wie Can WordPress really do that? A case study of vierderduer.no

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
references
 
The Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the QueryThe Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the Query
Chris Olbekson
 

Ähnlich wie Can WordPress really do that? A case study of vierderduer.no (20)

[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
 
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)
 
Scaling Complexity in WordPress Enterprise Apps
Scaling Complexity in WordPress Enterprise AppsScaling Complexity in WordPress Enterprise Apps
Scaling Complexity in WordPress Enterprise Apps
 
You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
 
Getting Creative with WordPress Queries
Getting Creative with WordPress QueriesGetting Creative with WordPress Queries
Getting Creative with WordPress Queries
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingWhy Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary Thing
 
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
 
Victoria wordpress
Victoria wordpressVictoria wordpress
Victoria wordpress
 
The Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the QueryThe Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the Query
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011
 
Solr's Search Relevancy (Understand Solr's query debug)
Solr's Search Relevancy (Understand Solr's query debug)Solr's Search Relevancy (Understand Solr's query debug)
Solr's Search Relevancy (Understand Solr's query debug)
 
QA for PHP projects
QA for PHP projectsQA for PHP projects
QA for PHP projects
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 
PHP Experience 2016 - [Workshop] Elastic Search: Turbinando sua aplicação PHP
PHP Experience 2016 - [Workshop] Elastic Search: Turbinando sua aplicação PHPPHP Experience 2016 - [Workshop] Elastic Search: Turbinando sua aplicação PHP
PHP Experience 2016 - [Workshop] Elastic Search: Turbinando sua aplicação PHP
 
Custom Post Types and Meta Fields
Custom Post Types and Meta FieldsCustom Post Types and Meta Fields
Custom Post Types and Meta Fields
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 

Mehr von Morten Rand-Hendriksen

Mehr von Morten Rand-Hendriksen (8)

How to Build Custom WordPress Blocks
How to Build Custom WordPress BlocksHow to Build Custom WordPress Blocks
How to Build Custom WordPress Blocks
 
Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0
 
How Not to Destroy the World: Ethics in Design and Technology
How Not to Destroy the World: Ethics in Design and TechnologyHow Not to Destroy the World: Ethics in Design and Technology
How Not to Destroy the World: Ethics in Design and Technology
 
How to Not Destroy the World - the Ethics of Web Design
How to Not Destroy the World - the Ethics of Web DesignHow to Not Destroy the World - the Ethics of Web Design
How to Not Destroy the World - the Ethics of Web Design
 
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
 
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
 
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
 
GitHub for the Rest of Us
GitHub for the Rest of UsGitHub for the Rest of Us
GitHub for the Rest of Us
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Can WordPress really do that? A case study of vierderduer.no