Skip to content

Instantly share code, notes, and snippets.

@ann71727
ann71727 / WordPress Plugin Header.php
Last active October 28, 2017 23:33
WordPress Plugin Header
<?php
/*
Plugin Name: Plug Name v123 DEV
Plugin URI: https://v123.tw
Description: 插件簡述
Version: 1.01.0
Author: v123 DEV
Author URI: https://v123.tw
License: GPL2
License URI: https://v123.tw
@ann71727
ann71727 / List All Post Type Names.php
Last active October 28, 2017 15:05
List All Post Type Names
<?php
/*
* List All Post Type Names
* https://v123.tw
*/
function v123_get_all_post_type_names(){
global $wp_post_types;
$posttypes = array_keys( $wp_post_types );
@ann71727
ann71727 / List All Post Type.php
Last active October 28, 2017 15:01
List All Post Type
<?php
/*
* List All Post Type
* https://v123.tw
*/
function v123_get_all_post_types(){
global $wp_post_types;
print_r($wp_post_types);
}
add_action('init','v123_get_all_post_types');
@ann71727
ann71727 / WP_Query_arr.php
Created October 27, 2017 19:04
WP_Query get posts Array
<?php
/*
* Convert Object To Array
* https://v123.tw
*/
function WP_Query_arr(array $args){
$default = array(
'showposts' => -1,
'post_type' => 'post',
@ann71727
ann71727 / WordPress-WP_Query-result-posts-object-to-an-array.php
Last active July 6, 2023 10:42
WordPress WP_Query() result posts object to an array
<?php
/*
* Convert Object To Array
* https://v123.tw
*/
$args = array(
'showposts' => -1,
'post_type' => 'post',
'post_status' => 'publish'
@ann71727
ann71727 / Convert Object To Array.php
Last active October 27, 2017 17:51
PHP Convert Object To Array
<?php
/*
* Convert Object To Array
* https://vector.cool
*/
function obj_to_arr($obj){
return (array) $obj;
}