2017-04-25 53 views
-2

如何解決這個簡碼?如何創建簡碼?

function post_id_shortcode_func() { 
Global $post; 
return full_real id = "' $post-> ID '"; 
} 
add_shortcode (' post_id_shortcode ', ' post_id_shortcode_func '); 

這是一個簡碼,而不$post-> ID

<? php 
do_shortcode (' [full_real id = "' $post-> ID '"] '); 
?> 

這基本上是一個簡碼的簡碼,而不PHP函數。

結果[full_real id = "current post id"]

與幾種貨幣

回答

0

試試這個代碼的變化的電子表格,

// Creating short code 
function full_real_func($atts){ 
     $a = shortcode_atts(array(
      'id' => '', //Provide any default id. 
     ), $atts); 

     return esc_attr($a['id']); //returns id. 
    } 
    add_shortcode('full_real', 'full_real_func'); 

//Calling 
echo do_shortcode('[full_real id="' .$post->ID .'"]'); 

希望這將幫助你!

+0

如果您有澄清請在下面評論。 有一個快樂的代碼。 – ganeshreddy

+0

我編輯了代碼,看看你現在可以幫我嗎? –