0
私はショートコードを使用しています。私はメインタイトル、サムネイル、一部のコンテンツ、そして私の投稿のパーマリンクが必要です。 しかし、この短いコードを使用してWordpressは、タイトル、サムネイル、およびパーマリンクのない完全なコンテンツを表示します。 私は今何をすべきですか? The photo of my style (注:これはショートコードの古い形式です) 助けてください。ショートコードWordPressのメインコンテンツでは機能しませんfild
これはこれはこれは、サムネイルのサポートのために
add_theme_support('post-thumbnails');
add_image_size('post-image', 145,100, true);
マイショートコード
である私のindex.php<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php else : ?>
<h3><?php _e('404 Error: Not Found'); ?></h3>
<?php endif; ?>
中に、あるのfunctions.php
function category_post_shortcode($atts){
extract(shortcode_atts(array(
'title' => '',
'link' => '',
'category' => '',
), $atts, 'category_post'));
$q = new WP_Query(
array('category' => $category, 'post_per_page' => '3', 'post_type' => 'post')
);
$list = '<div class="your_class"><h2>'.$title.'</h2> <a href="'.$link.'">more</a>';
while($q->have_posts()) : $q->the_post();
$id = get_the_ID();
$post_excerpt = get_post_meta($id, 'post_excerpt', true);
$post_thumbnail=get_the_post_thumbnail($post->ID,'post-thumbnail');
$list .= '
<div class="single-cat-post">
'.$post_thumbnail.'
<h3>'.get_the_title().'</h3>
<P>'.$post_excerpt.'</p>
<a href="'.get_permalink().'">read more</a>
</div>
';
endwhile;
$list.= '</div>';
wp_reset_query();
}
add_shortcode('category_post', 'category_post_shortcode');
にコードです
[category_post title="This is a testing post" category="New" link="#"]