我是在绞尽脑汁让这个代码工作,看到了吧。
我可以通过信件列出我的wordpress文章。
但我不能这样做,以便它显示以数字开头的文章。
查看我的代码
<?php
//get all post IDs for posts beginning with cap B, in title order,
//display posts
$first_char = '0-9';
$postids=$wpdb->get_col($wpdb->prepare("
SELECT ID
FROM $wpdb->posts
WHERE SUBSTR($wpdb->posts.post_title,1,1) = %s
ORDER BY $wpdb->posts.post_title",$first_char));
if ($postids) {
$args=array(
'post__in' => $postids,
'post_type' => ' ',
'tag' => 'anime-dublado',
'orderby' => 'title',
'order' => 'ASC',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo ' '. $first_char;
while ($my_query->have_posts()) : $my_query->the_post(); ?>
我已经尝试更改部分$first_char='0-9'; 只有一个数字,但只有一个文章出现。
我希望代码显示所有的文章,以数字开始,只有。
如果我可以放入代码$first_char='0,1,2,3,4,5,6,7,8,9,‘,就可以让它工作; 但我做不到
也许这个工作:
$FIRST_CHAR=“('0','1','2','3','4','5','6','7','8','9')”;
并在SQL查询中更改“=”for“in”
其中%s
中SUBSTR($WPDB->posts.post_title,1,1)