代码也可以在这里查看: https://codecopy.cn/post/zfke1x
----
php调用: echo do_shortcode('[DMblock]block/block01[/DMblock]');
或 wpdmblock('jthome_footer/footer01');
---------
page template是这样生成的:
<?php /* Template Name: Example Template */ ?>
------------------
如何知道wordpress当前页面使用了哪个模板文件? 模板覆盖规则>
在footer.php里加以下代码即可:
<?php
if(is_user_logged_in()){
global $template;
echo '<p style="background:red;color:#fff;text-align:center">'.basename($template).'</p>';
}
?>
----------------
<?php echo get_page_link(9) ?>
-----------
function.php里加下面代码:
function pre($v) {
echo '<pre>'.print_r($v,1).'</pre>';
}
---------
----------
<?php
if(is_user_logged_in()){
global $template;
echo '<p style="background:red;color:#fff;text-align:center">'.basename($template).'</p>';
}
?>
====================
function showmbfile(){
if(is_user_logged_in()){
global $template;
echo '<p style="background:red;color:#fff;text-align:center">模板文件:'.basename($template).'</p>';
}
}
function dmshowposttypes(){
if(is_user_logged_in()){
echo '<div style="font-size:22px;text-align:center">内容类型:';
// $v = get_post_type();
$v = get_post_types();
var_dump($v);
pre($v);
echo '</div>';
}
}
function dmshowtaxonomies(){
if(is_user_logged_in()){
echo '<div style="background:#083155;color:#fff;text-align:center">分类:';
// $v = get_post_type();
$v = get_taxonomies();
pre($v);
echo '</div>';
}
}
function dmshowterms($t='category'){
if(is_user_logged_in()){
echo '<div style="background:#085455;color:#fff;text-align:center">terms:';
// $v = get_post_type();
$v = get_terms($t);
pre($v);
echo '</div>';
}
}
---------------------
//echo WP_CONTENT_DIR;
//echo '<br />';
//echo WP_CONTENT_URL ;
----------------
define( 'WPDMPGROOT_WPDM', plugin_dir_path( __FILE__ ) );
define( 'WPDMPGROOT', plugin_dir_path( __DIR__ ) );
define( 'WPDMPGPATH_WPDM', plugin_dir_url( __FILE__ ) );
define( 'WPDMPGPATH', plugin_dir_url( __DIR__ ) );
//子主题:
define( 'WPDMPATH_MBCHILD', get_stylesheet_directory_uri () );
define( 'WPDMROOT_MBCHILD', get_stylesheet_directory () );
//父主题:
define( 'WPDMPATH_MB', get_template_directory_uri () );
define( 'WPDMROOT_MB', get_template_directory () );
$bshou=date("Ymd_His").rand(1000,9999);//is pidname
$dateall = date("Y-m-d H:i:s");
$dateday = date("Y-m-d");
-------------------------
define('DEFAULTIMGDIV','https://demosc.chinaz.net/Files/DownLoad/moban/202402/moban7700/images/img-2.png');
function get_nodedespjj($despjj,$desp,$desptext,$num){ //despjj = 内容简介
$rev = '';
if($despjj==''){
if($desptext<>'') $despv = $desptext;
else $despv = $desp;
}
else $despv = $despjj;
if($num>0){
$despv = strip_tags(web_despdecode($despv));
if(strlen($despv)>$num) $rev = mb_substr($despv,0,$num,'UTF-8').'...';
}
return $rev;
}