get_posts([
'meta_query' => [
// 'relation' => 'AND', // Optional, defaults to "AND"
[
'key' => '',
'value' => '', // array
//'type' => 'CHAR', // 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'
//'compare' => '=' // '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'EXISTS' and 'NOT EXISTS'. Default value is '='.
]
],
'posts_per_page' => -1,
'orderby' => 'date', //
'order' => 'ASC', // 'DESC'
'post_type' => 'post',
// 'post_status' => 'publish', // default: 'publish', []
// 'fields' => 'ids' // 'id=>parent'
]);
Last active
December 27, 2015 16:19
-
-
Save khoand0000/e13846753caaa07cc366 to your computer and use it in GitHub Desktop.
common wordpress functions
get_post($post_id)
returnWP_Post
get_posts($arg)
returnarray of WP_Post
WPFunctions::get_post($arg)
returnWP_Post
, my function
wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '')
return string HTMLimg
element, includewidth
andheight
attributeswp_get_attachment_thumb_url($post_id)
return Thumbnail URLwp_attachment_is_image( $post )
,$post is int|WP_Post
wp_get_attachment_url($post_id)
get_attached_file($attachment_id, $unfiltered = false)
return The file pathget_post_mime_type($post)
$post is int|WP_Post
return mime string (eg: image/png, text/csv, ...)
sanitize_file_name($file_name)
remove special characters, still keep unicode characters (vietnamese character)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment