Home Forums General Issues Query posts by custom fields Reply To: Query posts by custom fields

  • Hi @renee

    I believe you were talking about the current page slug where it shows the custom post type, right? In this case, I think you can get the current page slug like this:

    global $post;

    After that, you need to convert the page slug to the value you want like this:

    if( $page_slug == "slug1" ){
        $value = "value1";
    }elseif( $page_slug == "slug2" ){
        $value = "value2";
        $value = "value3";

    Then you can use it like this:

        'key' => 'product',
        'value' => $value,
        'compare' => '=',

    I hope this makes sense 🙂