0

i getting custom post by tag - my cod :

$search_videos = array(
    'posts_per_page' => -1,
    'post_type' => 'videos',
    'tag' => $search_query
    );  

    $new_query = new WP_Query( $search_videos );
    $search_videos_posts = $new_query->posts;

but by this code just return post that have complet tag but i want return posts if a part of tag word entered , return posts

EXAMPLE when search "akam" that return posts that have "akam" tag BUT by search "aka" (a part of word) ,that return nothing

1 Answer 1

0

Try this code as by using tag_slug__in, not tag.

$search_videos = array(
    'posts_per_page' => -1,
    'post_type' => 'videos',
    'tag_slug__in' => $search_query
    );  

    $new_query = new WP_Query( $search_videos );
    $search_videos_posts = $new_query->posts;
1
  • its work but just for all word not a part of word example : when search tag "akam" return posts that have "akam" tag but, if search tag "aka" , return nothing Nov 14, 2018 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.