请如何获取帖子标题, 我想在一页中列出20个帖子, 然后会有下一个按钮, 请帮助我
#1
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 20 // Number of Post you Want in a page
'paged' => $paged // Tells the current number of page in query
);
$my_query = new WP_Query( $args ); // adding custom query
while($custom_query->have_posts()) :
$custom_query->the_post();
the_title(); // Getting and printing the title of POST/Page
endwhile;
if (function_exists("pagination")) {
pagination($my_query->max_num_pages); // Calling pagination
} ?>
#2
你可以像@Asad所说的那样做。要在任何地方添加他的代码, 请在Wordpress存储库中下载插件Woody Ad Snippets:
Woody ad snippets – Insert Header Footer Code, AdSense Ads
并将PHP代码添加到通用代码段中。
#3
解析错误:语法错误, 意外的”分页”(T_CONSTANT_ENCAPSED_STRING), / home / woloade1 / public_html / wp-content / plugins / insert-php / includes / shortcodes / shortcode-universal.php(53)中的’)’ :第5行上的eval()代码
我收到这个错误
评论前必须登录!
注册