Class wp_posts

Description

wp_posts

A class for accessing posts from WordPress installs.

  • author: Samuel Parsons

Located in /wp_posts.php (line 14)


	
			
Class Constant Summary
Variable Summary
Method Summary
void __construct (resource $connection, [bool|id $multi_user_blog_id = false], [bool|array $categories = array()], [bool|array $categories_exclude = array()], [string $table_prefix = 'wp'])
bool|array get_categories ([int|bool $parent_id = false])
array|bool get_image_description_credits (string $image_location)
array get_post (int|string $post_name_or_id, [int|string $date_string = false])
array get_posts ([array $options_user = array()])
array get_post_categories (int $post_id)
string get_post_id (string $post_name, [int|string $date_string = false])
array get_post_meta (int $post_id, [string $meta_name = false])
Variables
mixed $categories = array() (line 31)
  • access: public
mixed $categories_by_slug = array() (line 32)
  • access: public
mixed $categories_ids = array() (line 33)
  • access: public
mixed $categories_slugs = array() (line 34)
  • access: public
mixed $category_tree = array() (line 35)
  • access: public
mixed $logs = array() (line 36)
  • access: public
mixed $results = false (line 30)
  • access: public
mixed $total_q_time (line 37)
  • access: public
Methods
Constructor __construct (line 75)

Constructs the wp_posts class.

  • author: Samuel Parsons
void __construct (resource $connection, [bool|id $multi_user_blog_id = false], [bool|array $categories = array()], [bool|array $categories_exclude = array()], [string $table_prefix = 'wp'])
  • resource $connection: Should be MySQL connection to a database containing a WordPress install.
  • bool|id $multi_user_blog_id: Optional id of wordpress blog if using a multisite install of WordPress. Default is false.
  • bool|array $categories: Optional categories to narrow results to. False or empty array means all categories. Default is array().
  • bool|array $categories_exclude: Optional categories to exclude from results. False or empty array means exclude none. Default is array().
  • string $table_prefix: Optionally specific the prefix before the WordPress tables. Default is 'wp'
get_categories (line 422)

Returns all categories or those within the optional parent category id.

  • return: Array
  • access: public
bool|array get_categories ([int|bool $parent_id = false])
  • int|bool $parent_id: (optional) parent category
get_image_description_credits (line 408)

Returns an array with title and description for a particular image that has been uploaded into the gallery.

  • return: Array if successful, false if not.
  • author: Samuel Parsons
  • access: public
array|bool get_image_description_credits (string $image_location)
  • string $image_location: The path to an image that has been uploaded.
get_post (line 285)

Retrieves a post given an post-ID or -slug.

  • return: or false
  • author: Samuel Parsons
  • access: public
array get_post (int|string $post_name_or_id, [int|string $date_string = false])
  • int|string $post_name_or_id: The ID or slug of a specific post to retrieve.
  • int|string $date_string: (optional) If an integer, treated as a timestamp. If a string, then strtotime() will be applied to it. By specifying a $date_string, the post will need to match this date in addition to the slug / ID
get_posts (line 112)

Fetches an array of posts from WordPress.

You give a set of options in an associative array (no specific order needed). Following is a list of keys and values for this array, all other keys will be discarded. If a value is not present, blank or not one of the allowed values then the default is used. 'categories' integer, string, or array of integers or strings, each referring to either a category id or slug respectively. 'limit' integer or array of integers. If an integer, it refers to the upper limit of number of posts to return. If an array, it should have two items: the first the starting item in the results, the second the number of posts to retrieve. 'order' string. Only the following are accepted. "time_asc", "time_desc" (default), "title_asc", "title_desc", "modified_desc", "modified_asc" 'time_span' array If set, the array should include two strings that when you apply strtotime() yield a valid time. The first string is the begin date, the second is the end date. 'meta_filter' associative array. If set, the assoc. array should have the following keys: 'key', 'value' (optional), 'type' (optional). The 'key' key should point at a string corresponding with a meta key. The 'value' key, if set, should point at a string that we'll compare with the meta values. The 'type' key, if set, should point to a string that is one of these: 'like', '=', '>', '<'. 'like' is the default. If only key is set, then the query will get posts that have that key declared. If key and value are set and type is not, then it will get posts that have that meta key LIKE the given meta value If key, value, and type are set, then it will get posts that have the meta key set such that it matches the given value in the way specified. 'exclude_sub_cats' bool. When false (default) posts that are in sub categories of the ones specified will be retrieved in addition to the posts in the categories specified. Setting this to true reverses the behavior. 'no_data' bool, default false. If set true, then returns just the number of results.

  • author: Samuel Parsons
  • access: public
array get_posts ([array $options_user = array()])
  • array $options_user: Options
get_post_categories (line 381)

Returns an array of categories that a post is tagged as.

  • return: or false
  • author: Samuel Parsons
  • access: public
array get_post_categories (int $post_id)
  • int $post_id: The ID of a post.
get_post_id (line 319)

Retrieves a post ID given post-slug.

  • return: or false
  • author: Samuel Parsons
  • access: public
string get_post_id (string $post_name, [int|string $date_string = false])
  • string $post_name: The slug of a specific post to retrieve.
  • int|string $date_string: (optional) If an integer, treated as a timestamp. If a string, then strtotime() will be applied to it. By specifying a $date_string, the post will need to match this date in addition to the slug / ID
get_post_meta (line 349)

Retrieves the meta for a particular post.

  • return: or false
  • author: Samuel Parsons
  • access: public
array get_post_meta (int $post_id, [string $meta_name = false])
  • int $post_id: The ID of a post.
  • string $meta_name: (optional) If specified returns just the posts values for that meta name.
Class Constants
default_version = '3.0.1' (line 16)
get_posts_categories_default = false (line 17)
get_posts_exclude_sub_cats_default = false (line 22)
get_posts_limit_default = 0 (line 18)
get_posts_meta_filter_default = false (line 21)
get_posts_no_data_default = false (line 23)
get_posts_order_default = 'time_desc' (line 19)
get_posts_time_span_default = 'all' (line 20)

Documentation generated on Thu, 11 Nov 2010 20:59:42 -0600 by phpDocumentor 1.4.3