Dragon主题购买
已解答
公开

请问评论邮件回复里面的推荐阅读是如何调用的,谢谢!

1 人关注这个问题

    1 答案

    公开

    主要利用了 tinection 主题 functions.php 里的下面这个函数:

    /* 简单相关文章(用于邮件)
    /* ------------------------------ */
    function dr_mail_related_post($postid){
        $tags = wp_get_post_tags($postid);
        $tagIDs = array();
        $related = '';
    
        if ($tags) {
            $tagcount = count($tags);
            for ($i = 0;$i <$tagcount;$i++) {
                $tagIDs[$i] = $tags[$i]->term_id;
            }
    
            $args=array(
                'tag__in'=>$tagIDs,
                'post__not_in'=>array($postid),
                'showposts'=>5,
                'orderby'=>'rand',
                'caller_get_posts'=>1
            );
    
            $my_query = new WP_Query($args);
            if( $my_query->have_posts() ) {
                $related = '<h3 style="padding-left:10px;margin:10px 0 5px;font-size:16px;font-weight:bold;border-left:3px solid #1cbdc5;line-height:25px;height:25px;">'.__('相关文章','tinection').'</h3><ul>';
    
                while ($my_query->have_posts()) : $my_query->the_post();
                    $related .= '<li style="list-style:circle;font-size:13px;"><a style="color:#1cbdc5;font-size:13px;font-family:微软雅黑,Microsoft Yahei;" href="'; $related .= get_permalink();
                    $related .= '" rel="bookmark" title="';
                    $related .= get_the_title($post->ID);
                    $related .= '">';
                    $related .= get_the_title($post->ID);
                    $related .= ' ( ';
                    $related .= get_comments_number($post->ID); $related .= ' ) ';
                    $related .= '</a></li>';
                endwhile;
    
                $related .= '</ul>';
            }
            wp_reset_postdata();
        }
    
        return $related;
    }

    然后用于邮件提醒中,改的有点小复杂,这里就...

    #1

    来提交答案

    扫一扫二维码分享
    ×
    We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies. Learn more
    Dragon