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

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

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