SlideShare a Scribd company logo
Web Designers Meetup Cairo - 17th November 2012




               Dig Deeper into
               WordPress
(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Why?
Have you ever thought



                      over 70-million websites out
                        there are using WordPress




(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Dig Deeper into WordPress - WD Meetup Cairo
flexi
                             WordPress main feature is




bility
(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Dig Deeper into WordPress - WD Meetup Cairo
Custom Post Types
Custom Meta Boxes
Custom Taxonomies
Advanced Queries
Custom Admin Panels/Options
Plugin API
Hooks, Actions and Filters
Customizable Advanced User Capabilities
+ many more....


(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Custom Post Types
           <?php register_post_type( $post_type,
                        $args ); ?>

	
  	
  $labels	
  =	
  array(
	
  	
  	
  	
  'name'	
  =>	
  _x('Books',	
  'post	
  type	
  general	
  name',	
  'your_text_domain'),
	
  	
  	
  	
  'singular_name'	
  =>	
  _x('Book',	
  'post	
  type	
  singular	
  name',	
  'your_text_domain'),
	
  	
  	
  	
  'add_new'	
  =>	
  _x('Add	
  New',	
  'book',	
  'your_text_domain'),
	
  	
  	
  	
  'add_new_item'	
  =>	
  __('Add	
  New	
  Book',	
  'your_text_domain'),
	
  	
  	
  	
  'edit_item'	
  =>	
  __('Edit	
  Book',	
  'your_text_domain'),
	
  	
  	
  	
  'new_item'	
  =>	
  __('New	
  Book',	
  'your_text_domain'),
	
  	
  	
  	
  'all_items'	
  =>	
  __('All	
  Books',	
  'your_text_domain'),
	
  	
  	
  	
  'view_item'	
  =>	
  __('View	
  Book',	
  'your_text_domain'),
	
  	
  	
  	
  'search_items'	
  =>	
  __('Search	
  Books',	
  'your_text_domain'),
	
  	
  	
  	
  'not_found'	
  =>	
  	
  __('No	
  books	
  found',	
  'your_text_domain'),
	
  	
  	
  	
  'not_found_in_trash'	
  =>	
  __('No	
  books	
  found	
  in	
  Trash',	
  'your_text_domain'),	
  
	
  	
  	
  	
  'parent_item_colon'	
  =>	
  '',
	
  	
  	
  	
  'menu_name'	
  =>	
  __('Books',	
  'your_text_domain')

	
  	
  );
	
  	
  $args	
  =	
  array(
	
  	
  	
  	
  'labels'	
  =>	
  $labels,
	
  	
  	
  	
  'public'	
  =>	
  true,
	
  	
  	
  	
  'publicly_queryable'	
  =>	
  true,
	
  	
  	
  	
  'show_ui'	
  =>	
  true,	
  
	
  	
  	
  	
  'show_in_menu'	
  =>	
  true,	
  
	
  	
  	
  	
  'query_var'	
  =>	
  true,
	
  	
  	
  	
  'rewrite'	
  =>	
  array(	
  'slug'	
  =>	
  _x(	
  'book',	
  'URL	
  slug',	
  'your_text_domain'	
  )	
  ),
	
  	
  	
  	
  'capability_type'	
  =>	
  'post',
	
  	
  	
  	
  'has_archive'	
  =>	
  true,	
  
	
  	
  	
  	
  'hierarchical'	
  =>	
  false,
	
  	
  	
  	
  'menu_position'	
  =>	
  null,
	
  	
  	
  	
  'supports'	
  =>	
  array(	
  'title',	
  'editor',	
  'author',	
  'thumbnail',	
  'excerpt',	
  'comments'	
  )
	
  	
  );	
  
	
  	
  register_post_type('book',	
  $args);

http://codex.wordpress.org/Function_Reference/register_post_type

(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Custom Meta Boxes
    <?php add_meta_box( $id, $title, $callback,
         $post_type, $context, $priority,
              $callback_args ); ?>
<?php
/*	
  Define	
  the	
  custom	
  box	
  */
add_action(	
  'add_meta_boxes',	
  'myplugin_add_custom_box'	
  );

/*	
  Do	
  something	
  with	
  the	
  data	
  entered	
  */
add_action(	
  'save_post',	
  'myplugin_save_postdata'	
  );

/*	
  Adds	
  a	
  box	
  to	
  the	
  main	
  column	
  on	
  the	
  Post	
  and	
  Page	
  edit	
  screens	
  */
function	
  myplugin_add_custom_box()	
  {
	
  	
  	
  	
  add_meta_box(	
  
	
  	
  	
  	
  	
  	
  	
  	
  'myplugin_sectionid',
	
  	
  	
  	
  	
  	
  	
  	
  __(	
  'My	
  Post	
  Section	
  Title',	
  'myplugin_textdomain'	
  ),
	
  	
  	
  	
  	
  	
  	
  	
  'myplugin_inner_custom_box',
	
  	
  	
  	
  	
  	
  	
  	
  'post'	
  
	
  	
  	
  	
  );
}

/*	
  Prints	
  the	
  box	
  content	
  */
function	
  myplugin_inner_custom_box(	
  $post	
  )	
  {

	
  	
  //	
  Use	
  nonce	
  for	
  verification
	
  	
  wp_nonce_field(	
  plugin_basename(	
  __FILE__	
  ),	
  'myplugin_noncename'	
  );

	
  	
  //	
  The	
  actual	
  fields	
  for	
  data	
  entry
	
  	
  echo	
  '<label	
  for="myplugin_new_field">';
	
  	
  	
  	
  	
  	
  	
  _e("Description	
  for	
  this	
  field",	
  'myplugin_textdomain'	
  );
	
  	
  echo	
  '</label>	
  ';
	
  	
  echo	
  '<input	
  type="text"	
  id="myplugin_new_field"	
  name="myplugin_new_field"	
  value="whatever"	
  size="25"	
  />';
}
..........

http://codex.wordpress.org/Function_Reference/add_meta_box

(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Custom Meta Boxes (cont.)

/*	
  When	
  the	
  post	
  is	
  saved,	
  saves	
  our	
  custom	
  data	
  */
function	
  myplugin_save_postdata(	
  $post_id	
  )	
  {
	
  	
  //	
  verify	
  if	
  this	
  is	
  an	
  auto	
  save	
  routine.	
  
	
  	
  //	
  If	
  it	
  is	
  our	
  form	
  has	
  not	
  been	
  submitted,	
  so	
  we	
  dont	
  want	
  to	
  do	
  anything
	
  	
  if	
  (	
  defined(	
  'DOING_AUTOSAVE'	
  )	
  &&	
  DOING_AUTOSAVE	
  )	
  
	
  	
  	
  	
  	
  	
  return;

	
  	
  if	
  (	
  !wp_verify_nonce(	
  $_POST['myplugin_noncename'],	
  plugin_basename(	
  __FILE__	
  )	
  )	
  )
	
  	
  	
  	
  	
  	
  return;
	
  	
  
	
  	
  //if	
  saving	
  in	
  a	
  custom	
  table,	
  get	
  post_ID
	
  	
  $post_ID	
  =	
  $_POST['post_ID'];
	
  	
  $mydata	
  =	
  $_POST['myplugin_new_field'];

	
  	
  //	
  Do	
  something	
  with	
  $mydata	
  
	
  	
  //	
  probably	
  using	
  add_post_meta(),	
  update_post_meta(),	
  or	
  
	
  	
  //	
  a	
  custom	
  table	
  (see	
  Further	
  Reading	
  section	
  below)
}
?>




(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Custom Taxonomies
          <?php register_taxonomy($taxonomy,
                $object_type, $args); ?>

	
  	
  //	
  Add	
  new	
  taxonomy,	
  make	
  it	
  hierarchical	
  (like	
  categories)
	
  	
  $labels	
  =	
  array(
	
  	
  	
  	
  'name'	
  =>	
  _x(	
  'Genres',	
  'taxonomy	
  general	
  name'	
  ),
	
  	
  	
  	
  'singular_name'	
  =>	
  _x(	
  'Genre',	
  'taxonomy	
  singular	
  name'	
  ),
	
  	
  	
  	
  'search_items'	
  =>	
  	
  __(	
  'Search	
  Genres'	
  ),
	
  	
  	
  	
  'all_items'	
  =>	
  __(	
  'All	
  Genres'	
  ),
	
  	
  	
  	
  'parent_item'	
  =>	
  __(	
  'Parent	
  Genre'	
  ),
	
  	
  	
  	
  'parent_item_colon'	
  =>	
  __(	
  'Parent	
  Genre:'	
  ),
	
  	
  	
  	
  'edit_item'	
  =>	
  __(	
  'Edit	
  Genre'	
  ),	
  
	
  	
  	
  	
  'update_item'	
  =>	
  __(	
  'Update	
  Genre'	
  ),
	
  	
  	
  	
  'add_new_item'	
  =>	
  __(	
  'Add	
  New	
  Genre'	
  ),
	
  	
  	
  	
  'new_item_name'	
  =>	
  __(	
  'New	
  Genre	
  Name'	
  ),
	
  	
  	
  	
  'menu_name'	
  =>	
  __(	
  'Genre'	
  ),
	
  	
  );	
  	
  

	
  	
  register_taxonomy('genre',array('book'),	
  array(
	
  	
  	
  	
  'hierarchical'	
  =>	
  true,
	
  	
  	
  	
  'labels'	
  =>	
  $labels,
	
  	
  	
  	
  'show_ui'	
  =>	
  true,
	
  	
  	
  	
  'query_var'	
  =>	
  true,
	
  	
  	
  	
  'rewrite'	
  =>	
  array(	
  'slug'	
  =>	
  'genre'	
  ),
	
  	
  ));




http://codex.wordpress.org/Taxonomies

(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Custom Taxonomies
  <?php register_taxonomy($taxonomy,
        $object_type, $args); ?>

	
  	
  //	
  Add	
  new	
  taxonomy,	
  NOT	
  hierarchical	
  (like	
  tags)
	
  	
  $labels	
  =	
  array(
	
  	
  	
  	
  'name'	
  =>	
  _x(	
  'Writers',	
  'taxonomy	
  general	
  name'	
  ),
	
  	
  	
  	
  'singular_name'	
  =>	
  _x(	
  'Writer',	
  'taxonomy	
  singular	
  name'	
  ),
	
  	
  	
  	
  'search_items'	
  =>	
  	
  __(	
  'Search	
  Writers'	
  ),
	
  	
  	
  	
  'popular_items'	
  =>	
  __(	
  'Popular	
  Writers'	
  ),
	
  	
  	
  	
  'all_items'	
  =>	
  __(	
  'All	
  Writers'	
  ),
	
  	
  	
  	
  'parent_item'	
  =>	
  null,
	
  	
  	
  	
  'parent_item_colon'	
  =>	
  null,
	
  	
  	
  	
  'edit_item'	
  =>	
  __(	
  'Edit	
  Writer'	
  ),	
  
	
  	
  	
  	
  'update_item'	
  =>	
  __(	
  'Update	
  Writer'	
  ),
	
  	
  	
  	
  'add_new_item'	
  =>	
  __(	
  'Add	
  New	
  Writer'	
  ),
	
  	
  	
  	
  'new_item_name'	
  =>	
  __(	
  'New	
  Writer	
  Name'	
  ),
	
  	
  	
  	
  'separate_items_with_commas'	
  =>	
  __(	
  'Separate	
  writers	
  with	
  commas'	
  ),
	
  	
  	
  	
  'add_or_remove_items'	
  =>	
  __(	
  'Add	
  or	
  remove	
  writers'	
  ),
	
  	
  	
  	
  'choose_from_most_used'	
  =>	
  __(	
  'Choose	
  from	
  the	
  most	
  used	
  writers'	
  ),
	
  	
  	
  	
  'menu_name'	
  =>	
  __(	
  'Writers'	
  ),
	
  	
  );	
  

	
  	
  register_taxonomy('writer','book',array(
	
  	
  	
  	
  'hierarchical'	
  =>	
  false,
	
  	
  	
  	
  'labels'	
  =>	
  $labels,
	
  	
  	
  	
  'show_ui'	
  =>	
  true,
	
  	
  	
  	
  'update_count_callback'	
  =>	
  '_update_post_term_count',
	
  	
  	
  	
  'query_var'	
  =>	
  true,
	
  	
  	
  	
  'rewrite'	
  =>	
  array(	
  'slug'	
  =>	
  'writer'	
  ),
	
  	
  ));




http://codex.wordpress.org/Taxonomies

(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Advanced Queries
<?php $the_query = new WP_Query( $args ); ?>
WP_Query is a class defined in wp-includes/query.php that deals with the intricacies of a posts
(or pages) request to a WordPress blog. The wp-blog-header.php (or the WP class in Version 2.0)
gives the $wp_query object information defining the current request, and then $wp_query
determines what type of query it's dealing with (possibly a category archive, dated archive,
feed, or search), and fetches the requested posts. It retains a lot of information on the
request, which can be pulled at a later date.



<?php
$args=	
  array(
	
  	
  	
  	
  	
  .
	
  	
  	
  	
  	
  .
);
$query=	
  new	
  WP_Query($args);

//	
  Loop
while($query-­‐>have_posts()):
	
  	
  	
  	
  	
  $query-­‐>next_post();
	
  	
  	
  	
  	
  $id	
  =	
  $query-­‐>post-­‐>ID;
	
  	
  	
  	
  	
  echo	
  '<li>';
	
  	
  	
  	
  	
  echo	
  get_the_title($id);
	
  	
  	
  	
  	
  echo	
  '</li>';
endwhile;
?>




http://codex.wordpress.org/Class_Reference/WP_Query

(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Advanced Queries (cont.)
<?php $the_query = new WP_Query( $args ); ?>


Class Methods                                         Parameters
- init()
- parse_query( $query )
- parse_query_vars()
- get( $query_var )
- set( $query_var, $value )
- &get_posts()
- next_post()
- the_post()
- rewind_posts()
- &query( $query )
- get_queried_object()
- get_queried_object_id()
- WP_Query( $query = '' ) (constructor)




http://codex.wordpress.org/Class_Reference/WP_Query

(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Advanced Queries (cont.)
   <?php $wpdb->get_results( MYSQLQuery ); ?>

The $wpdb object can be used to read data from any table in the WordPress database, not just the standard
tables that WordPress creates.

$wpdb-­‐>query(	
  
	
                    $wpdb-­‐>prepare(	
  
	
                    	
                    "
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  DELETE	
  FROM	
  $wpdb-­‐>postmeta
	
                    	
                    	
  WHERE	
  post_id	
  =	
  %d
	
                    	
                    	
  AND	
  meta_key	
  =	
  %s
	
                    	
                    ",
	
                    	
  	
  	
  	
  	
  	
  	
  	
  13,	
  'gargle'	
  
	
  	
  	
  	
  	
  	
  	
  	
  )
);

or	
  

$wpdb-­‐>query(
	
    "
	
    UPDATE	
  $wpdb-­‐>posts	
  
	
    SET	
  post_parent	
  =	
  7
	
    WHERE	
  ID	
  =	
  15	
  
	
    	
      AND	
  post_status	
  =	
  'static'
	
    "
);




http://codex.wordpress.org/Class_Reference/wpdb

(C) 2012 Mohamed Mosaad. All Copyrights Reserved
Scan My vCard

   wpmonkeys.com

   fb.com/banhawi

   be.net/banhawi

   eg.linkedin.com/in/banhawi

   twitter.com/banhawi

   www.                  .com




▼
▼ http://bit.ly/Xh5EiB
Thank You
§   Mohamed Mosaad
    UX Evangelist & WordPress Expert
    wpmonkeys.com
Ad

More Related Content

What's hot (19)

Your code sucks, let's fix it (CakeFest2012)
Your code sucks, let's fix it (CakeFest2012)Your code sucks, let's fix it (CakeFest2012)
Your code sucks, let's fix it (CakeFest2012)
Rafael Dohms
 
Drupal & javascript
Drupal & javascriptDrupal & javascript
Drupal & javascript
Almog Baku
 
Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016
Colin O'Dell
 
Apache Solr Search Mastery
Apache Solr Search MasteryApache Solr Search Mastery
Apache Solr Search Mastery
Acquia
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
musrath mohammad
 
WooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda BagusWooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda Bagus
WordCamp Indonesia
 
Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片
cfc
 
WordPress as an application framework
WordPress as an application frameworkWordPress as an application framework
WordPress as an application framework
Dustin Filippini
 
Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysql
Knoldus Inc.
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
Anis Ahmad
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created it
Paul Bearne
 
WordPress Capabilities Magic
WordPress Capabilities MagicWordPress Capabilities Magic
WordPress Capabilities Magic
mannieschumpert
 
Custom Post Types and Meta Fields
Custom Post Types and Meta FieldsCustom Post Types and Meta Fields
Custom Post Types and Meta Fields
Liton Arefin
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
Marco Vito Moscaritolo
 
Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3
Karsten Dambekalns
 
Coding for Scale and Sanity
Coding for Scale and SanityCoding for Scale and Sanity
Coding for Scale and Sanity
JimKellerES
 
Disregard Inputs, Acquire Zend_Form
Disregard Inputs, Acquire Zend_FormDisregard Inputs, Acquire Zend_Form
Disregard Inputs, Acquire Zend_Form
Daniel Cousineau
 
jQuery
jQueryjQuery
jQuery
Jay Poojara
 
Entities in drupal 7
Entities in drupal 7Entities in drupal 7
Entities in drupal 7
Zsolt Tasnadi
 
Your code sucks, let's fix it (CakeFest2012)
Your code sucks, let's fix it (CakeFest2012)Your code sucks, let's fix it (CakeFest2012)
Your code sucks, let's fix it (CakeFest2012)
Rafael Dohms
 
Drupal & javascript
Drupal & javascriptDrupal & javascript
Drupal & javascript
Almog Baku
 
Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016
Colin O'Dell
 
Apache Solr Search Mastery
Apache Solr Search MasteryApache Solr Search Mastery
Apache Solr Search Mastery
Acquia
 
WooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda BagusWooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda Bagus
WordCamp Indonesia
 
Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片
cfc
 
WordPress as an application framework
WordPress as an application frameworkWordPress as an application framework
WordPress as an application framework
Dustin Filippini
 
Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysql
Knoldus Inc.
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
Anis Ahmad
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created it
Paul Bearne
 
WordPress Capabilities Magic
WordPress Capabilities MagicWordPress Capabilities Magic
WordPress Capabilities Magic
mannieschumpert
 
Custom Post Types and Meta Fields
Custom Post Types and Meta FieldsCustom Post Types and Meta Fields
Custom Post Types and Meta Fields
Liton Arefin
 
Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3
Karsten Dambekalns
 
Coding for Scale and Sanity
Coding for Scale and SanityCoding for Scale and Sanity
Coding for Scale and Sanity
JimKellerES
 
Disregard Inputs, Acquire Zend_Form
Disregard Inputs, Acquire Zend_FormDisregard Inputs, Acquire Zend_Form
Disregard Inputs, Acquire Zend_Form
Daniel Cousineau
 
Entities in drupal 7
Entities in drupal 7Entities in drupal 7
Entities in drupal 7
Zsolt Tasnadi
 

Similar to Dig Deeper into WordPress - WD Meetup Cairo (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
Adam 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 Types
Alex Blackie
 
Working with WooCommerce Custom Fields
Working with WooCommerce Custom FieldsWorking with WooCommerce Custom Fields
Working with WooCommerce Custom Fields
Anthony Hortin
 
WordCamp Denver 2012 - Custom Meta Boxes
WordCamp Denver 2012 - Custom Meta BoxesWordCamp Denver 2012 - Custom Meta Boxes
WordCamp Denver 2012 - Custom Meta Boxes
Jeremy Green
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutes
Barang CK
 
WordPress for developers - phpday 2011
WordPress for developers -  phpday 2011WordPress for developers -  phpday 2011
WordPress for developers - phpday 2011
Maurizio Pelizzone
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
Leonardo Proietti
 
WordPress Cuztom Helper
WordPress Cuztom HelperWordPress Cuztom Helper
WordPress Cuztom Helper
slicejack
 
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
allilevine
 
Migrare da symfony 1 a Symfony2
 Migrare da symfony 1 a Symfony2  Migrare da symfony 1 a Symfony2
Migrare da symfony 1 a Symfony2
Massimiliano Arione
 
MTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APIMTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new API
Six Apart KK
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
Daniel Knell
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
Stephan Hochdörfer
 
WordPress plugin #3
WordPress plugin #3WordPress plugin #3
WordPress plugin #3
giwoolee
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
Michelangelo van Dam
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Balázs Tatár
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
DrupalDay
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
Michelangelo van Dam
 
Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012
Mike Schinkel
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
Fabien Potencier
 
[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
Adam 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 Types
Alex Blackie
 
Working with WooCommerce Custom Fields
Working with WooCommerce Custom FieldsWorking with WooCommerce Custom Fields
Working with WooCommerce Custom Fields
Anthony Hortin
 
WordCamp Denver 2012 - Custom Meta Boxes
WordCamp Denver 2012 - Custom Meta BoxesWordCamp Denver 2012 - Custom Meta Boxes
WordCamp Denver 2012 - Custom Meta Boxes
Jeremy Green
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutes
Barang CK
 
WordPress for developers - phpday 2011
WordPress for developers -  phpday 2011WordPress for developers -  phpday 2011
WordPress for developers - phpday 2011
Maurizio Pelizzone
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
Leonardo Proietti
 
WordPress Cuztom Helper
WordPress Cuztom HelperWordPress Cuztom Helper
WordPress Cuztom Helper
slicejack
 
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
allilevine
 
MTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APIMTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new API
Six Apart KK
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
Daniel Knell
 
WordPress plugin #3
WordPress plugin #3WordPress plugin #3
WordPress plugin #3
giwoolee
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Balázs Tatár
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
DrupalDay
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
Michelangelo van Dam
 
Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012
Mike Schinkel
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
Fabien Potencier
 
Ad

Recently uploaded (20)

Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Ad

Dig Deeper into WordPress - WD Meetup Cairo

  • 1. Web Designers Meetup Cairo - 17th November 2012 Dig Deeper into WordPress (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 2. Why? Have you ever thought over 70-million websites out there are using WordPress (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 4. flexi WordPress main feature is bility (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 6. Custom Post Types Custom Meta Boxes Custom Taxonomies Advanced Queries Custom Admin Panels/Options Plugin API Hooks, Actions and Filters Customizable Advanced User Capabilities + many more.... (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 7. Custom Post Types <?php register_post_type( $post_type, $args ); ?>    $labels  =  array(        'name'  =>  _x('Books',  'post  type  general  name',  'your_text_domain'),        'singular_name'  =>  _x('Book',  'post  type  singular  name',  'your_text_domain'),        'add_new'  =>  _x('Add  New',  'book',  'your_text_domain'),        'add_new_item'  =>  __('Add  New  Book',  'your_text_domain'),        'edit_item'  =>  __('Edit  Book',  'your_text_domain'),        'new_item'  =>  __('New  Book',  'your_text_domain'),        'all_items'  =>  __('All  Books',  'your_text_domain'),        'view_item'  =>  __('View  Book',  'your_text_domain'),        'search_items'  =>  __('Search  Books',  'your_text_domain'),        'not_found'  =>    __('No  books  found',  'your_text_domain'),        'not_found_in_trash'  =>  __('No  books  found  in  Trash',  'your_text_domain'),          'parent_item_colon'  =>  '',        'menu_name'  =>  __('Books',  'your_text_domain')    );    $args  =  array(        'labels'  =>  $labels,        'public'  =>  true,        'publicly_queryable'  =>  true,        'show_ui'  =>  true,          'show_in_menu'  =>  true,          'query_var'  =>  true,        'rewrite'  =>  array(  'slug'  =>  _x(  'book',  'URL  slug',  'your_text_domain'  )  ),        'capability_type'  =>  'post',        'has_archive'  =>  true,          'hierarchical'  =>  false,        'menu_position'  =>  null,        'supports'  =>  array(  'title',  'editor',  'author',  'thumbnail',  'excerpt',  'comments'  )    );      register_post_type('book',  $args); http://codex.wordpress.org/Function_Reference/register_post_type (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 8. Custom Meta Boxes <?php add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args ); ?> <?php /*  Define  the  custom  box  */ add_action(  'add_meta_boxes',  'myplugin_add_custom_box'  ); /*  Do  something  with  the  data  entered  */ add_action(  'save_post',  'myplugin_save_postdata'  ); /*  Adds  a  box  to  the  main  column  on  the  Post  and  Page  edit  screens  */ function  myplugin_add_custom_box()  {        add_meta_box(                  'myplugin_sectionid',                __(  'My  Post  Section  Title',  'myplugin_textdomain'  ),                'myplugin_inner_custom_box',                'post'          ); } /*  Prints  the  box  content  */ function  myplugin_inner_custom_box(  $post  )  {    //  Use  nonce  for  verification    wp_nonce_field(  plugin_basename(  __FILE__  ),  'myplugin_noncename'  );    //  The  actual  fields  for  data  entry    echo  '<label  for="myplugin_new_field">';              _e("Description  for  this  field",  'myplugin_textdomain'  );    echo  '</label>  ';    echo  '<input  type="text"  id="myplugin_new_field"  name="myplugin_new_field"  value="whatever"  size="25"  />'; } .......... http://codex.wordpress.org/Function_Reference/add_meta_box (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 9. Custom Meta Boxes (cont.) /*  When  the  post  is  saved,  saves  our  custom  data  */ function  myplugin_save_postdata(  $post_id  )  {    //  verify  if  this  is  an  auto  save  routine.      //  If  it  is  our  form  has  not  been  submitted,  so  we  dont  want  to  do  anything    if  (  defined(  'DOING_AUTOSAVE'  )  &&  DOING_AUTOSAVE  )              return;    if  (  !wp_verify_nonce(  $_POST['myplugin_noncename'],  plugin_basename(  __FILE__  )  )  )            return;        //if  saving  in  a  custom  table,  get  post_ID    $post_ID  =  $_POST['post_ID'];    $mydata  =  $_POST['myplugin_new_field'];    //  Do  something  with  $mydata      //  probably  using  add_post_meta(),  update_post_meta(),  or      //  a  custom  table  (see  Further  Reading  section  below) } ?> (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 10. Custom Taxonomies <?php register_taxonomy($taxonomy, $object_type, $args); ?>    //  Add  new  taxonomy,  make  it  hierarchical  (like  categories)    $labels  =  array(        'name'  =>  _x(  'Genres',  'taxonomy  general  name'  ),        'singular_name'  =>  _x(  'Genre',  'taxonomy  singular  name'  ),        'search_items'  =>    __(  'Search  Genres'  ),        'all_items'  =>  __(  'All  Genres'  ),        'parent_item'  =>  __(  'Parent  Genre'  ),        'parent_item_colon'  =>  __(  'Parent  Genre:'  ),        'edit_item'  =>  __(  'Edit  Genre'  ),          'update_item'  =>  __(  'Update  Genre'  ),        'add_new_item'  =>  __(  'Add  New  Genre'  ),        'new_item_name'  =>  __(  'New  Genre  Name'  ),        'menu_name'  =>  __(  'Genre'  ),    );        register_taxonomy('genre',array('book'),  array(        'hierarchical'  =>  true,        'labels'  =>  $labels,        'show_ui'  =>  true,        'query_var'  =>  true,        'rewrite'  =>  array(  'slug'  =>  'genre'  ),    )); http://codex.wordpress.org/Taxonomies (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 11. Custom Taxonomies <?php register_taxonomy($taxonomy, $object_type, $args); ?>    //  Add  new  taxonomy,  NOT  hierarchical  (like  tags)    $labels  =  array(        'name'  =>  _x(  'Writers',  'taxonomy  general  name'  ),        'singular_name'  =>  _x(  'Writer',  'taxonomy  singular  name'  ),        'search_items'  =>    __(  'Search  Writers'  ),        'popular_items'  =>  __(  'Popular  Writers'  ),        'all_items'  =>  __(  'All  Writers'  ),        'parent_item'  =>  null,        'parent_item_colon'  =>  null,        'edit_item'  =>  __(  'Edit  Writer'  ),          'update_item'  =>  __(  'Update  Writer'  ),        'add_new_item'  =>  __(  'Add  New  Writer'  ),        'new_item_name'  =>  __(  'New  Writer  Name'  ),        'separate_items_with_commas'  =>  __(  'Separate  writers  with  commas'  ),        'add_or_remove_items'  =>  __(  'Add  or  remove  writers'  ),        'choose_from_most_used'  =>  __(  'Choose  from  the  most  used  writers'  ),        'menu_name'  =>  __(  'Writers'  ),    );      register_taxonomy('writer','book',array(        'hierarchical'  =>  false,        'labels'  =>  $labels,        'show_ui'  =>  true,        'update_count_callback'  =>  '_update_post_term_count',        'query_var'  =>  true,        'rewrite'  =>  array(  'slug'  =>  'writer'  ),    )); http://codex.wordpress.org/Taxonomies (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 12. Advanced Queries <?php $the_query = new WP_Query( $args ); ?> WP_Query is a class defined in wp-includes/query.php that deals with the intricacies of a posts (or pages) request to a WordPress blog. The wp-blog-header.php (or the WP class in Version 2.0) gives the $wp_query object information defining the current request, and then $wp_query determines what type of query it's dealing with (possibly a category archive, dated archive, feed, or search), and fetches the requested posts. It retains a lot of information on the request, which can be pulled at a later date. <?php $args=  array(          .          . ); $query=  new  WP_Query($args); //  Loop while($query-­‐>have_posts()):          $query-­‐>next_post();          $id  =  $query-­‐>post-­‐>ID;          echo  '<li>';          echo  get_the_title($id);          echo  '</li>'; endwhile; ?> http://codex.wordpress.org/Class_Reference/WP_Query (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 13. Advanced Queries (cont.) <?php $the_query = new WP_Query( $args ); ?> Class Methods Parameters - init() - parse_query( $query ) - parse_query_vars() - get( $query_var ) - set( $query_var, $value ) - &get_posts() - next_post() - the_post() - rewind_posts() - &query( $query ) - get_queried_object() - get_queried_object_id() - WP_Query( $query = '' ) (constructor) http://codex.wordpress.org/Class_Reference/WP_Query (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 14. Advanced Queries (cont.) <?php $wpdb->get_results( MYSQLQuery ); ?> The $wpdb object can be used to read data from any table in the WordPress database, not just the standard tables that WordPress creates. $wpdb-­‐>query(     $wpdb-­‐>prepare(       "                                DELETE  FROM  $wpdb-­‐>postmeta      WHERE  post_id  =  %d      AND  meta_key  =  %s     ",                  13,  'gargle'                  ) ); or   $wpdb-­‐>query(   "   UPDATE  $wpdb-­‐>posts     SET  post_parent  =  7   WHERE  ID  =  15       AND  post_status  =  'static'   " ); http://codex.wordpress.org/Class_Reference/wpdb (C) 2012 Mohamed Mosaad. All Copyrights Reserved
  • 15. Scan My vCard wpmonkeys.com fb.com/banhawi be.net/banhawi eg.linkedin.com/in/banhawi twitter.com/banhawi www. .com ▼ ▼ http://bit.ly/Xh5EiB
  • 16. Thank You § Mohamed Mosaad UX Evangelist & WordPress Expert wpmonkeys.com