Wordpress类别发布列表插件自定义


Wordpress Category Post List Plugin Customisation

我希望你能帮我解决这个难题。。。

我正在尝试自定义Wordpress类别帖子列表插件,以便它在短代码中的帖子标题下列出帖子类别。

<a class="wp-cpl-info" href="<?php echo get_permalink($post->ID); ?>" title="<?php echo __('Permalink to: ', $trans) . $post->post_title; ?>">
<h2><?php echo get_the_title($post->ID); ?></h2>
<span class="cross">X</span>
<span class="details"><?php $categories = get_categories( $args ); ?></span>
</a>

我试图找到当前代码所在位置的Wordpress php函数(这只是猜测)。插件输出代码的其余部分表明了什么是可能的。。。

<?php if($op['show_date'] == 'true' || $op['show_author'] == 'true' || $op['show_comments'] == 'true') : ?>
<div class="wp-cpl-sc-meta">
    <p>
        <?php if($op['show_date'] == 'true') : ?>
        <span class="wp-cpl-sc-date"><?php echo __('Posted on ', $trans) . date('M jS, Y', strtotime($post->post_date)) . ' '; ?></span>
        <?php endif; ?>
        <?php if($op['show_author'] == 'true') : ?>
        <span class="wp-cpl-sc-author"><?php echo __(' - By ', $trans) . '<a href="' . get_the_author_meta('user_url', $post->post_author) . '">' . get_the_author_meta('display_name', $post->post_author) . '</a> '; ?></span>
        <?php endif; ?>
        <?php if($op['show_comments'] == 'true') : ?>
        <span class="wp-cpl-sc-comment"><?php echo ' - <a href="' . get_comments_link($post->ID) . '">' . $post->comment_count . ' ' . __ngettext('Comment', 'Comments', $post->comment_count, $trans) . '</a>' ?></span>
        <?php endif; ?>
    </p>
</div>
<?php endif; ?>
<?php if($op['show_excerpt'] == 'true') : ?>
<div class="wp-cpl-sc-entry">
    <p>
        <?php echo (('true' == $op['optional_excerpt'] && $post->post_excerpt != '')? $post->post_excerpt : itgdb_wp_cpl_loader::shorten_string($post->post_content, $op['excerpt_length'])); ?>
    </p>
    <?php if('' != $op['read_more']) : ?>
    <p class="wp-cpl-sc-readmore">
        <a href="<?php echo get_permalink($post->ID); ?>"><?php echo $op['read_more']; ?></a>
    </p>
    <?php endif; ?>
</div>

所有这些代码都属于插件includes文件夹中的wp_cpl_output_gen.php代码。

希望这一切都有意义!基本上,我正在创建这样的东西,所以我需要能够显示类别。

非常感谢!

Kathryn

我刚刚想明白了,很抱歉,如果这个问题很复杂,我不知道我到底在找什么,直到我明白了…

基本上我需要的类别相当于:

<?php echo get_the_title($post->ID); ?>

事实证明,这并不复杂-请参阅http://codex.wordpress.org/Function_Reference/get_the_category供参考-并变为:

<?php echo get_the_category($post->ID); ?>

谢谢大家!