0

我正在使用一个名为 Category Thumbnail list 的插件。我通常会将钩子[categorythumbnaillist 100]放在我的 Wordpress 页面上。如何将其添加到实际的 php 页面?

http://wordpress.org/extend/plugins/categoy-thumbnail-list/

插件代码:

$categoryThumbnailList_Order = stripslashes( get_option( 'category-thumbnail-list_order' ) );
if ($categoryThumbnailList_Order == '') {
$categoryThumbnailList_Order = 'date';
 }
$categoryThumbnailList_OrderType = stripslashes( get_option( 'category-thumbnail-list_ordertype' ) );
if ($categoryThumbnailList_OrderType == '') {
$categoryThumbnailList_OrderType = 'DESC';
}

$categoryThumbnailList_Path = get_option('siteurl')."/wp-content/plugins/categoy-thumbnail-list/";

define("categoryThumbnailList_REGEXP", "/\[categorythumbnaillist ([[:print:]]+)\]/");

define("categoryThumbnailList_TARGET", "###CATTHMBLST###");

function categoryThumbnailList_callback($listCatId) {
global $post;

global $categoryThumbnailList_Order;

global $categoryThumbnailList_OrderType;

$tmp_post = $post; 

$myposts = get_posts('numberposts=-1&&category='.$listCatId[1].'&&orderby='.$categoryThumbnailList_OrderType.'&&order='.$categoryThumbnailList_Order);
$output = '<div class="categoryThumbnailList">';
foreach($myposts as $post) :
    setup_postdata($post);
    if ( has_post_thumbnail() ) {
    $link = get_permalink($post->ID);
    $thmb = get_the_post_thumbnail($post->ID,'thumbnail');

    $title = get_the_title();

    $output .= '<div class="categoryThumbnailList_item">';
        $output .= '<a href="' .$link . '" title="' .$title . '">' .$thmb . '</a><br/>';
        $output .= '<a href="' .$link . '" title="' .$title . '">' .$title . '</a>';
    $output .= '</div>';
    }
endforeach;
/*
$output .= '</div>';
$output .= '<div class="categoryThumbnailList_clearer"></div>';
return ($output);
$output = '';
$post = $tmp_post;
setup_postdata($post);
*/
$output .= '</div>';
$output .= '<div class="categoryThumbnailList_clearer"></div>';

$post = $tmp_post;

wp_reset_postdata();

return ($output);

$output = '';
}

function categoryThumbnailList($content) {
return (preg_replace_callback(categoryThumbnailList_REGEXP,        'categoryThumbnailList_callback', $content));

}

function categoryThumbnailList_css() {
global $categoryThumbnailList_Path;
echo "
<style type=\"text/css\">
@import url(\"".$categoryThumbnailList_Path."categoy-thumbnail-list.css\");
</style>
";
}
add_action('wp_head', 'categoryThumbnailList_css');
add_filter('the_content', 'categoryThumbnailList',1);
?>
4

1 回答 1

0

我想你想在模板文件中添加短代码。将此行放在您的 index.php 中

<?php echo do_shortcode( '[categorythumbnaillist 100]' ); ?> 
于 2012-04-27T04:48:45.333 回答