大家好,我是这里的新手,我一直在寻找这个答案,但我想我没有找到用谷歌搜索这个问题的正确方法。
我不懂PHP,但我非常了解html和css,我正在个性化一个wordpress,以便在主页上显示X个数量的帖子,并按照我的意愿进行格式化。
我在wordpress网站上找到了这个例子
<ul>
<?php
$args = array( \'numberposts\' => \'5\', \'tax_query\' => array(
array(
\'taxonomy\' => \'post_format\',
\'field\' => \'slug\',
\'terms\' => \'post-format-aside\',
\'operator\' => \'NOT IN\'
),
array(
\'taxonomy\' => \'post_format\',
\'field\' => \'slug\',
\'terms\' => \'post-format-image\',
\'operator\' => \'NOT IN\'
)
) );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo \'<li><a href="\' . get_permalink($recent["ID"]) . \'">\' . ( __($recent["post_title"])).\'</a> </li> \';
}
?>
</ul>
但它所做的只是打印链接,当我想摘录标题、内容以及是否有图片附在帖子上,以及图片时。我不知道插入什么样的参数,以及如何定义语法。如果有人能帮忙,我将不胜感激,并为我的无知感到抱歉。
UPDATE
没有什么我以为我明白了,但没有。我完全被代码迷住了。UPDATE 2
我正在尝试使用当前代码:query_posts(\'show_posts=2\');
while ( have_posts() ) : the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
echo \'<div class="txt">\';
the_title();
the_excerpt();
echo \'</div>\';
// End the loop.
endwhile;
// Reset Query
wp_reset_query();
但是posts参数不起作用,它只打印我所有的post。我知道需要将query post参数分配给while函数。不知道怎么做。