maryam300 1 ارسال شده در اسفند 95 گزارش بازنشر ارسال شده در اسفند 95 سلام آیا کدی هست که با درج آن در متن نوشته یا برگه، عنوان اون نوشته یا برگه در متنش بیافته. مثلا عنوان برگه "وردپرس" هست. در متن اون برگه نوشته بشه. " سلام <وردپرس> " لینک به ارسال
amin20100 69 ارسال شده در اسفند 95 گزارش بازنشر ارسال شده در اسفند 95 میتونید از شورتکد ها استفاده کنید بعنوان مثال کد زیر رو اگه توی functions.php قرار بدید یه شرتکد میسازه به اسم "[my-title]" <?php /** * Title shortcode * */ class my_title_shortcode{ /** * $shortcode_tag * holds the name of the shortcode tag * @var string */ public $shortcode_tag = 'my-title'; /** * __construct * class constructor will set the needed filter and action hooks * * @param array $args */ function __construct($args = array()){ //add shortcode add_shortcode( $this->shortcode_tag, array( $this, 'shortcode_handler' ) ); } /** * shortcode_handler * @param array $atts shortcode attributes * @param string $content shortcode content * @return string */ function shortcode_handler( $atts, $content = null ) { // Attributes extract( shortcode_atts( array( 'id' => '', ), $atts ) ); if( ! $id ) { global $post; $id = $post->ID; } $output = ''; $output = apply_filters( 'the_title', get_post( $id )->post_title ); return $output; } } new my_title_shortcode(); و هرجای متن که بنویسید [my-title] عنوان رو نشون میده. 1 لینک به ارسال
maryam300 1 ارسال شده در اسفند 95 مالک گزارش بازنشر ارسال شده در اسفند 95 دوست عزیز مرسی.عالی بود. 1 لینک به ارسال
پست های پیشنهاد شده
لطفا برای ارسال دیدگاه وارد شوید
شما بعد از اینکه وارد حساب کاربری خود شدید می توانید دیدگاهی ارسال کنید
ورود به حساب کاربری