Function Reference: geodir_get_post_info

Summary

Get post custom fields.

Global Values

$wpdb
(object) (required) WordPress Database object.

Default: None
$post
(object) (required) The current post object.

Default: None
$plugin_prefix
(string) (required) Geodirectory plugin table prefix.

Default: None

Package

GeoDirectory

Parameters

$post_id
(int|string) (optional) The post ID.

Default: None

Return Values

(object|bool)
  • Returns full post details as an object.
  • If no details returns false.

Change Log

Since: 1.0.0

Filters

‘geodir_post_info_query’ [Line: 592]

Source File

geodir_get_post_info() is located in geodirectory-functions/post_functions.php [Line: 567]

Source Code

function geodir_get_post_info($post_id = '')
{

    global $wpdb, $plugin_prefix, $post, $post_info;

    if ($post_id == '' && !empty($post))
        $post_id = $post->ID;

    $post_type = get_post_type($post_id);

    $all_postypes = geodir_get_posttypes();

    if (!in_array($post_type, $all_postypes))
        return false;

    $table = $plugin_prefix . $post_type . '_detail';

    /**
     * Apply Filter to change Post info
     *
     * You can use this filter to change Post info.
     *
     * @since 1.0.0
     * @package GeoDirectory
     */
    $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
			  WHERE p.ID = pd.post_id
			  AND pd.post_id = %d", $post_id));

    $post_detail = $wpdb->get_row($query);

    return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false;

}