0

「jazz」で始まる投稿だけを返す LIKE パラメータを渡す次のコードを取得できません。

    <?php 
$artist_post_title = 'jazz'
    $args = array(
    'post_type' => 'artists',
    'post_title' => '%' . $artist_post_title
);

?>

<?php $user_query = new WP_Query( $args); ?> 

<?php if( $user_query->have_posts() ) : ?>
    <?php while ( $user_query->have_posts() ) : $user_query->the_post(); ?>
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
    <?php endwhile; ?>
    <?php wp_reset_postdata(); // reset the query ?>
<?php endif; ?>
4

1 に答える 1

2

私はあなたの質問に興味をそそられ、自分自身を掘り下げました。

https://wordpress.stackexchange.com/questions/18703/wp-query-with-post-title-like-something

基本的に、WP_Query のフィルターを定義することで、正確な結果セットを作成できます。

于 2013-09-05T00:48:51.673 に答える