2012-04-27 16 views
0

カテゴリサムネイルリストと呼ばれるプラグインを使用しています。私は通常、私のWordpressのページにフック[categorythumbnaillist 100]を配置します。これを実際のPHPページにどのように追加できますか?Wordpressのプラグインフックをindex.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); 
?> 

答えて

0

私はあなたがadd short-code in template fileにしたいと思います。この行をあなたのindex.phpに入れてください。

<?php echo do_shortcode('[categorythumbnaillist 100]'); ?> 
+0

ちょうど '[categorythumbnaillist 100]'をページのテキストとして出力しました。他の解決策? – McGuyverr

+0

ねえ、McGuyverr、あなたにとっては悪いニュースです...現時点では、categorythumbnaillistはコアwp_contentエリアの外側に配置されていないため、エディタでのみ動作します... – Denish

+0

これを行う簡単なスクリプトを記述できますか? – McGuyverr

関連する問題