lp__get_meta( $post )
Get post meta from custom table. Retrieves the meta data associated with a specific post from a custom table.
Plugin
Namespace
Launchpad
Parameters
int
$post
ID of the post.
Return
array|array[]|null
Array of post meta data. Returns null if no meta data is found.
Source
File: \includes\lp-utility-functions.php
function lp__get_meta( $post ){
global $wpdb;
$value_search = [];
$value_search[] = 1;
$value_search[] = $post;
$post_type = get_post_type( $post );
if( lp__table_exists($post_type) ){
$sql = "SELECT * FROM {$wpdb->prefix}{$post_type}
WHERE %d AND post_id = %s";
$total_query = "SELECT COUNT(1) FROM ({$sql}) AS combined_table";
$totalItems = $wpdb->get_var( $wpdb->prepare( $total_query , $value_search ) );
$sql = $wpdb->prepare( $sql , $value_search);
$data = $wpdb->get_results($sql ,'ARRAY_A');
} else {
$data = [];
}
return !empty($data) ? $data[0] : $data;
}