Month: May 2008

PHP : Array to Object

I wrote a quick and simple function which allows you to quickly convert arrays to objects. It allows you to change an array like this : $a['b']; To an object like this : $a -> b; The quickest way to do this is with typecasting: $a = array('b'); $a = (object) $a; //$a is now an object Or below is a manual function to achieve it. Have fun! function array_to_object($array = array()) { if (!empty($array)) { $data = false; foreach ($array as $akey => $aval) { $data -> {$akey} = $aval; } return $data; } return false;...

Read More

WordPress : get_pages

The WordPress get_pages function works similar to the get_posts function which fetches posts from the database by criteria. The get_pages function takes different arguments and allows you to take control of parent and child pages as you execute the function. Usage : <?php $pages = get_pages($arguments); ?> Example : <?php $arguments = array( 'child_of' => 0, 'sort_order' => "DESC", 'sort_column' => "post_title", 'exclude' => "3,7,8", ); $pages = get_pages($arguments); ?> Parameters : $child_of The ID of the parent page. Allows you to fetch child pages of a specific parent page. Use 0 or null or false in order to fetch all parent and child pages. $sort_order The direction in which the results should be sorted. This can be either ASC or DESC. Works in conjunction with the $sort_column parameter explained below. $sort_column The database column to order by. Makes use of the $sort_order parameter explained above. $exclude Comma delimited list of page IDs to exclude from the results $include Comma delimited list of page IDs to include into the results $authors Comma delimited list of the authors to which the pages belong. Only pages created by these authors will be included into the results $meta_key Matches a specific meta key and only includes those pages into the results $meta_value Matches a specific meta value and only includes those pages into the results $hierarchical If set to 1, pages will...

Read More

Stay up to date

Get one email per month with latest news. You can unsubscribe at any time


Fill in a valid email

captcha

"; -->

Pin It on Pinterest

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!