Monday, September 26, 2022
HomeWordPress DevelopmentHow do I've a number of metaqueries inside one wordpress question

How do I’ve a number of metaqueries inside one wordpress question


I’ve a parent->baby relationship between artists and releases. There’s one other parent->baby relationship between releases and variations aka albums, singles, movies, misc.

So artist is the grandparent of model.

I am utilizing a wp question to search out all model posts that belong to an artist. This works nice, yay for me!

I’ve added some customized fields to the launch degree, together with that includes and associated to. I might like this identical question to tug all variations that belong to a launch that has the artist listed in one in every of these fields.

My drawback is, I am unable to wrap my head round the right way to embrace launch publish kind in as properly. this is my present code.

$args = array(
    'post_type' => array('single','album','movies','misc'),
    'posts_per_page' => -1,
    'meta_query' => array(
        array(
            array(
                'relation' => 'AND',
                'format' => array(
                    'key' => 'wpcf-format',
                ),
                'nation' => array(
                    'key' => 'wpcf-country-of-release',
                ),
                '12 months' => array(
                    'key' => 'wpcf-release-year',
                    
                ),
                'label' => array(
                    'key' => 'wpcf-label',
                ),
                'artist' => array(
                    array(
                        'relation' => 'OR',
                        'mainartist'=> array(
                            'key' => $queriedartistid,
                        'worth' => $thispostartistid,
                        ),
                        'splitartist'=> array(
                            'key' => $splitartist,
                        'worth' => $thispostartistid,
                        ),
                        'relatedto'=> array(
                            'key' => $relatedto,
                        'worth' => $thispostartistid,
                        ),
                        'that includes'=> array(
                            'key' => $that includes,
                        'worth' => $thispostartistid,
                        ),
                        'performedby'=> array(
                            'key' => $performedby,
                        'worth' => $thispostartistid,
                        ),
                        'variousartist'=> array(
                            'key' => $variousartist,
                        'worth' => $thispostartistid,
                        ),
                    ),
                        
                ),
                'launch' => array(
                    'key' => '_wpcf_belongs_release_id',
                    
                ),
                'bootleg' => array(
                    'key' => 'wpcf-bootleg',
                ),
                
                'catalogue' => array(
                    'key' => 'wpcf-catalogue-number',
                ),
                ),
                
            ),
        ),
    
'orderby' => array(
    '12 months' => 'ASC',
    'format' => 'ASC',
    'nation' => 'ASC',
    'label' => 'ASC',
    'catalogue' => 'ASC',
    'other_info_empty' => 'ASC',
    'other_info_there' => 'ASC',
    )
); 

The issue is in my artist array. The search is just searching for variations, which haven’t got the meta fields ‘that includesorassociated to` and so on. These are within the model degree.

How can I construction this question to incorporate additionally variations of releases with the artist listed in these meta fields?

In English:
present all variations, the place the meta-key '_wpcf_belongs_release_id' matches a launch which has the customized meta-key related_to with a worth of $thispostartistid. How can I embrace that on this question?

Thanks, I believe it is a sophisticated technique to write this query, trying ahead to feedback that assist me clear up and make my query clearer.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments