wordpress代码

添加shortcode, breadcrumb

https://codecopy.cn/post/8raa5t

在function.php:

require get_template_directory ().'/incdm/incfunction.php';

------


<?php 
//-------
//子主题:

 //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 () );

if(is_int(strpos($_SERVER['QUERY_STRING'],'&action=elementor')))  define('DMEDITELEACTION','y');
else define('DMEDITELEACTION','n');  

 

function artbellfile_shortcode( $atts, $content = null ) {   
  //[DMboxlinkbtn class="more6 morelg"  link="products"]更多产品[/DMboxlinkbtn]
    extract(shortcode_atts(array(
         'class' => '',         
         'file' => '',         
    ), $atts));
   $classv = $class==''?'':$class;
   $rev = '';
  // $rev = ' <div class="tc dmbtn mt10 '.$classv.'"><a class="more" href="about.html">'.$content.'</a></div>';

      $file = get_template_directory ().'/incdm/'.$file.'.php'; 
    if(is_file($file)){  
        require $file;
      
      }
      else    echo '<p style="padding:10px;background:red;color:#fff">...'.substr($file,-50).'不存在</p>';

   return $rev;
}


 //  [DM blockid]idddddddd[/DM blockid]
//echo do_shortcode('[contact-form-7 id="44" title="Main Contact Form"]');
add_shortcode( 'artbellfile', 'artbellfile_shortcode' );
 

-------------

breadlist.php:


< ? php 
  if(DMEDITELEACTION<>'y') {

  $term = get_queried_object();  
  // pre($term); 

 $curtaxo = $term->taxonomy;
 $termlink = get_term_link($term->term_id,$curtaxo);

$parent = $term->parent;

$parentv = '';
if($parent<>0) {

     $pterm = get_term( $term->parent,$curtaxo);
   $ptermlink = get_term_link($term->parent, $curtaxo);
 
   $pterm_name = $pterm->name;


    $parentv = ' > <a href="'.$ptermlink.'">'.$pterm_name.'</a>';


?>

<a href="<?php echo site_url()?>">Home</a> >
<a href="https://artbellfitness.com/product/">Product</a>
 <?php echo $parentv?>  > <a href="<?php echo $termlink?>"><?php echo $term->name?></a>

<?php 
  }
  
-------

breadsingle.php


< ? php 
 
  if(DMEDITELEACTION<>'y') {

  //$term = get_queried_object();  
  //pre($term); 

  $post_id = get_the_ID();
  $post_title = get_the_title();

  //echo $post_title;

  $curtaxo = get_post_taxonomies($post_id)[0];

  $term = get_the_terms($post_id, $curtaxo )[0];


//pre($term); 


 $curtaxo = $term->taxonomy;
 $termlink = get_term_link($term->term_id,$curtaxo);

$parent = $term->parent;

$parentv = '';
if($parent<>0) {

     $pterm = get_term( $term->parent,$curtaxo);
   $ptermlink = get_term_link($term->parent, $curtaxo);
 
   $pterm_name = $pterm->name;


    $parentv = ' > <a href="'.$ptermlink.'">'.$pterm_name.'</a>';


?>

<a href="<?php echo site_url()?>">Home</a> <?php echo $parentv?>  > <a href="<?php echo $termlink?>"><?php echo $term->name?></a>
> <?php echo $post_title?>


<?php 
  }
 

------------------