This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get the pages 1,2 and 3 and do some things with them | |
with_posts("1,2,3'", function() { | |
echo "<p>Found a post with title: " . get_the_title() . "</p>"; | |
}); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Setup a wp_query object that gets the pages with id 1,2 and 3 | |
$query = new wp_query('post_type=page&post__in=1,2,3'); | |
while ($query->have_posts() ) : | |
$query->the_post(); | |
echo "<p>Found a post with title: " . get_the_title() . "</p>"; | |
endwhile; | |
wp_reset_postdata(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WordPress WP_QUERY-wrapper to simplify getting and working with posts | |
* | |
* Does something with posts, using a callback | |
* Setups global post variable before running callback | |
* And restores it afterwards | |
* | |
* An introductionary blogpost about this function is posted on our blog: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Examples for WordPress function with_posts() | |
* | |
* The main function is available here: | |
* https://gist.github.com/bonny/5011943 | |
* | |
* Author and contact info: | |
* https//twitter.com/eskapism |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[date_only] => Array | |
( | |
[type] => date | |
[date_unixtime] => 1351900800 | |
[ISO_8601] => 2012-11-03 | |
[RFC_2822] => Sat, 03 Nov 2012 00:00:00 +0000 | |
[Y-m-d] => 2012-11-03 | |
[date_format] => November 3, 2012 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[id] => 1 | |
[first_name] => phil | |
[last_name] => roberts | |
[user_login] => phil | |
[user_email] => [email protected] | |
[user_nicename] => philly | |
[display_name] => philly | |
[user] => WP_User Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[saved_value] => 27/10/2012 | |
[timestamp] => 1351296000 | |
[date_format] => October 27, 2012 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[terms] => Array | |
( | |
[0] => Array | |
( | |
[name] => Uncategorized | |
[slug] => uncategorized | |
[id] => 1 | |
[term] => stdClass Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[name] => category | |
[singular_name] => Category | |
[plural_name] => Categories | |
[taxonomy] => stdClass Object | |
( | |
[hierarchical] => 1 | |
[update_count_callback] => | |
[rewrite] => Array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[id] => 41 | |
[title] => Post to test extended return values | |
[permalink] => http://example.com/wordpress/?p=41 | |
[post] => stdClass Object | |
( | |
[ID] => 41 | |
[post_author] => 1 | |
[post_date] => 2012-10-19 13:58:19 |