SlideShare uma empresa Scribd logo
1 de 6
Baixar para ler offline
Undercover Pods 
/ WP Functions 
Scott Kingsley Clark, @scottkclark 
Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014
Looping with Pods and zebra / nth 
$params = array( 
'orderby' => 't.created DESC', 
'limit' => 25 
); 
$pods = pods( 'article', $params ); 
?> 
<h2>Latest 25 articles</h2> 
<?php 
while ( $pods->fetch() ) { 
$class = ''; 
if ( $pods->zebra() ) { // Every odd item 
$class = ' class="odd"'; 
} elseif ( $pods->nth( '4n+0' ) ) { // Every fourth item, using nth-child CSS syntax 
$class = ' class="fourth"'; 
} 
?> 
<p><a href="<?php echo esc_url( $pods->field( 'detail_url' ) ); ?>"><?php echo $pods->index(); ?></a></p> 
<?php 
} 
Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014
Filtering lists and grabbing properties with wp_list_filter and wp_list_pluck 
$foods = array( 
Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014 
array( 
'name' => 'Banana', 
'color' => 'Yellow', 
), 
array( 
'name' => 'Apple', 
'color' => 'Red', 
) 
); 
$food_names = wp_list_pluck( $foods, 'name' ); 
// $food_names is now 
$food_names = array( 
'Banana', 
'Apple' 
); 
$foods = array( 
array( 
'name' => 'Banana', 
'color' => 'Yellow', 
), 
array( 
'name' => 'Apple', 
'color' => 'Red', 
) 
); 
$red_foods = wp_list_filter( $foods, array( 'color' => 'Red' 
) ); 
// $red_foods is now 
$red_foods = array( 
array( 
'name' => 'Apple', 
'color' => 'Red', 
) 
);
Manipulating field Pods data with add_to / remove_from 
$pods = pods( 'article', 345 ); 
$pods->add_to( 'category', 123 ); // Relationship fields (add 123 to list) 
$pods->add_to( 'count', 1 ); // Number fields (+1) 
$pods->add_to( 'next_date', '+5 days' ); // Date fields (add time to field) 
$pods->add_to( 'post_content', "nnMore text to add to this field.." ); // Text fields (append text to 
content) 
$pods->remove_from( 'category', 123 ); // Relationship fields (remove 123 to list) 
$pods->remove_from( 'count', 1 ); // Number fields (-1) 
$pods->remove_from( 'next_date', '-5 days' ); // Date fields (remove time to field) 
Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014
Checking against values of Pods fields while in loops with is / has 
$pods = pods( 'article', array( 'limit' => 25 ) ); 
while ( $pods->fetch() ) { 
// Check if count === 14 
if ( $pods->is( 'count', 14 ) ) { 
echo 'Counting is... AWESOME!'; 
} 
// Check if next_date === 10/03/2014 
elseif ( $pods->is( 'next_date', '10/03/2014' ) ) { 
echo 'Dates are... AWESOME!'; 
} 
// Check if post_content === 'N/A' 
elseif ( $pods->is( 'post_content', 'N/A' ) ) { 
echo 'Content is... AWESOME!'; 
} 
} 
while ( $pods->fetch() ) { 
Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014 
// Check if category has 123 (even if multiple set) 
if ( $pods->has( 'category', 123 ) ) { 
echo 'I can haz category 123!'; 
} 
// Check if post_content contains 'OMG' 
elseif ( $pods->has( 'post_content', 'OMG' ) ) { 
echo 'I can haz OMG!'; 
} 
}
Pods Media Functions and wp_prepare_attachment_for_js 
echo pods_image( 
$pods->field( 'thumbnail' ), // Image ID, guid, or field value array 
'thumbnail', // Image size to get <img> for 
123 // Default if arg 1 is empty 
); 
// Import an attachment, give it a post parent if needed, and maybe set as featured image 
$attachment_id = pods_attachment_import( $url, $post_parent, $featured ); 
// Resize an image on demand to any specific size 
// in string or array( 'width' => 100, 'height' => 150, 'crop' => false ) format 
$success = pods_image_resize( $attachment_id, $size ); 
// Get EVERYTHING from an attachment, width, height, 
// size array with every bit of info you could ever dream of 
$attachment_data_zomg = wp_prepare_attachment_for_js( $attachment_id ); 
Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014

Mais conteúdo relacionado

Mais procurados

YAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービスYAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービス
Yusuke Wada
 
Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
Yusuke Wada
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
Michael Peacock
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro Framework
Jeremy Kendall
 
Decoupling Objects With Standard Interfaces
Decoupling Objects With Standard InterfacesDecoupling Objects With Standard Interfaces
Decoupling Objects With Standard Interfaces
Thomas Weinert
 
Dealing with Continuous Data Processing, ConFoo 2012
Dealing with Continuous Data Processing, ConFoo 2012Dealing with Continuous Data Processing, ConFoo 2012
Dealing with Continuous Data Processing, ConFoo 2012
Michael Peacock
 

Mais procurados (20)

YAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービスYAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービス
 
Current state-of-php
Current state-of-phpCurrent state-of-php
Current state-of-php
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 
Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
 
solving little problems
solving little problemssolving little problems
solving little problems
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
 
Symfony without the framework
Symfony without the frameworkSymfony without the framework
Symfony without the framework
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro Framework
 
Decoupling Objects With Standard Interfaces
Decoupling Objects With Standard InterfacesDecoupling Objects With Standard Interfaces
Decoupling Objects With Standard Interfaces
 
New in php 7
New in php 7New in php 7
New in php 7
 
Dealing with Continuous Data Processing, ConFoo 2012
Dealing with Continuous Data Processing, ConFoo 2012Dealing with Continuous Data Processing, ConFoo 2012
Dealing with Continuous Data Processing, ConFoo 2012
 

Destaque

Pictures of different types of limestone
Pictures of different types of limestonePictures of different types of limestone
Pictures of different types of limestone
Heather3673
 
Building Materials for Construction
Building Materials for Construction Building Materials for Construction
Building Materials for Construction
Ajjay Kumar Gupta
 

Destaque (20)

Grow Beyond Posts & Pages: Introduction to the Pods Framework, a Content Mana...
Grow Beyond Posts & Pages: Introduction to the Pods Framework, a Content Mana...Grow Beyond Posts & Pages: Introduction to the Pods Framework, a Content Mana...
Grow Beyond Posts & Pages: Introduction to the Pods Framework, a Content Mana...
 
Cement
CementCement
Cement
 
Pictures of different types of limestone
Pictures of different types of limestonePictures of different types of limestone
Pictures of different types of limestone
 
Properties of Aggregate and cement
Properties of Aggregate and cementProperties of Aggregate and cement
Properties of Aggregate and cement
 
3. lime
3. lime3. lime
3. lime
 
Types of bonds
Types of bondsTypes of bonds
Types of bonds
 
Introduction to dental cements dental material
Introduction to dental cements dental materialIntroduction to dental cements dental material
Introduction to dental cements dental material
 
Limestone
LimestoneLimestone
Limestone
 
Aggregate - Concrete Technology
Aggregate - Concrete TechnologyAggregate - Concrete Technology
Aggregate - Concrete Technology
 
Dental cement dental material
Dental cement dental materialDental cement dental material
Dental cement dental material
 
Properties of aggregrate
Properties of aggregrateProperties of aggregrate
Properties of aggregrate
 
Cement
CementCement
Cement
 
Aggregates of Concrete
Aggregates of ConcreteAggregates of Concrete
Aggregates of Concrete
 
Properties of Cement
Properties of CementProperties of Cement
Properties of Cement
 
Aggregates ppt
Aggregates pptAggregates ppt
Aggregates ppt
 
Stone masonary
Stone masonaryStone masonary
Stone masonary
 
Bamboo construction (final ppt)
Bamboo construction (final ppt)Bamboo construction (final ppt)
Bamboo construction (final ppt)
 
Construction material lime
Construction material limeConstruction material lime
Construction material lime
 
MODALS PPT
MODALS PPTMODALS PPT
MODALS PPT
 
Building Materials for Construction
Building Materials for Construction Building Materials for Construction
Building Materials for Construction
 

Semelhante a Undercover Pods / WP Functions

Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHP
Hari K T
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
chuvainc
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Masahiro Nagano
 
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
camp_drupal_ua
 
Zendcon 2007 Api Design
Zendcon 2007 Api DesignZendcon 2007 Api Design
Zendcon 2007 Api Design
unodelostrece
 

Semelhante a Undercover Pods / WP Functions (20)

What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
 
Drupal 8 database api
Drupal 8 database apiDrupal 8 database api
Drupal 8 database api
 
Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHP
 
PHP API
PHP APIPHP API
PHP API
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
 
Daily notes
Daily notesDaily notes
Daily notes
 
Drupal7 dbtng
Drupal7  dbtngDrupal7  dbtng
Drupal7 dbtng
 
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
 
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
 
Drupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary EditionDrupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary Edition
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutes
 
50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
 
Wp query
Wp queryWp query
Wp query
 
Zendcon 2007 Api Design
Zendcon 2007 Api DesignZendcon 2007 Api Design
Zendcon 2007 Api Design
 
Drupal is Stupid (But I Love It Anyway)
Drupal is Stupid (But I Love It Anyway)Drupal is Stupid (But I Love It Anyway)
Drupal is Stupid (But I Love It Anyway)
 
JavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to knowJavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to know
 
JavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to knowJavaScript in Drupal 7: What developers need to know
JavaScript in Drupal 7: What developers need to know
 

Último

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

Undercover Pods / WP Functions

  • 1. Undercover Pods / WP Functions Scott Kingsley Clark, @scottkclark Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014
  • 2. Looping with Pods and zebra / nth $params = array( 'orderby' => 't.created DESC', 'limit' => 25 ); $pods = pods( 'article', $params ); ?> <h2>Latest 25 articles</h2> <?php while ( $pods->fetch() ) { $class = ''; if ( $pods->zebra() ) { // Every odd item $class = ' class="odd"'; } elseif ( $pods->nth( '4n+0' ) ) { // Every fourth item, using nth-child CSS syntax $class = ' class="fourth"'; } ?> <p><a href="<?php echo esc_url( $pods->field( 'detail_url' ) ); ?>"><?php echo $pods->index(); ?></a></p> <?php } Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014
  • 3. Filtering lists and grabbing properties with wp_list_filter and wp_list_pluck $foods = array( Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014 array( 'name' => 'Banana', 'color' => 'Yellow', ), array( 'name' => 'Apple', 'color' => 'Red', ) ); $food_names = wp_list_pluck( $foods, 'name' ); // $food_names is now $food_names = array( 'Banana', 'Apple' ); $foods = array( array( 'name' => 'Banana', 'color' => 'Yellow', ), array( 'name' => 'Apple', 'color' => 'Red', ) ); $red_foods = wp_list_filter( $foods, array( 'color' => 'Red' ) ); // $red_foods is now $red_foods = array( array( 'name' => 'Apple', 'color' => 'Red', ) );
  • 4. Manipulating field Pods data with add_to / remove_from $pods = pods( 'article', 345 ); $pods->add_to( 'category', 123 ); // Relationship fields (add 123 to list) $pods->add_to( 'count', 1 ); // Number fields (+1) $pods->add_to( 'next_date', '+5 days' ); // Date fields (add time to field) $pods->add_to( 'post_content', "nnMore text to add to this field.." ); // Text fields (append text to content) $pods->remove_from( 'category', 123 ); // Relationship fields (remove 123 to list) $pods->remove_from( 'count', 1 ); // Number fields (-1) $pods->remove_from( 'next_date', '-5 days' ); // Date fields (remove time to field) Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014
  • 5. Checking against values of Pods fields while in loops with is / has $pods = pods( 'article', array( 'limit' => 25 ) ); while ( $pods->fetch() ) { // Check if count === 14 if ( $pods->is( 'count', 14 ) ) { echo 'Counting is... AWESOME!'; } // Check if next_date === 10/03/2014 elseif ( $pods->is( 'next_date', '10/03/2014' ) ) { echo 'Dates are... AWESOME!'; } // Check if post_content === 'N/A' elseif ( $pods->is( 'post_content', 'N/A' ) ) { echo 'Content is... AWESOME!'; } } while ( $pods->fetch() ) { Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014 // Check if category has 123 (even if multiple set) if ( $pods->has( 'category', 123 ) ) { echo 'I can haz category 123!'; } // Check if post_content contains 'OMG' elseif ( $pods->has( 'post_content', 'OMG' ) ) { echo 'I can haz OMG!'; } }
  • 6. Pods Media Functions and wp_prepare_attachment_for_js echo pods_image( $pods->field( 'thumbnail' ), // Image ID, guid, or field value array 'thumbnail', // Image size to get <img> for 123 // Default if arg 1 is empty ); // Import an attachment, give it a post parent if needed, and maybe set as featured image $attachment_id = pods_attachment_import( $url, $post_parent, $featured ); // Resize an image on demand to any specific size // in string or array( 'width' => 100, 'height' => 150, 'crop' => false ) format $success = pods_image_resize( $attachment_id, $size ); // Get EVERYTHING from an attachment, width, height, // size array with every bit of info you could ever dream of $attachment_data_zomg = wp_prepare_attachment_for_js( $attachment_id ); Undercover Pods / WP Functions // Scott Kingsley Clark // PodsCamp 2014