Support

Account

Home Forums General Issues Creating a query based on Taxonomy field

Unread

Creating a query based on Taxonomy field

  • Hi everyone,

    I am trying to create a query based on the taxonomy field. To give a bit of background, I have an internal links CPT with the taxonomy field, which pulls from the regular post categories. This is used to create a block of internal links which will be displayed on blog posts. My code will check the post category/categories and then find links that have been assigned with that post category.

    $internal_links = get_posts( array(
        'post_type' => 'bf_internal_links',
        'meta_query'	=> array(
    		array(
    			'key'		=> 'categorieen',
    			'value'		=> '1',
    			'compare'	=> 'LIKE'
    		),
    	)
    ) );

    Here’s how I am getting the links. I thought that I’d be able to put the actual category name under value, but that doesn’t work. When I checked the database I see no words under value at all, just “1” and that query does work. The aim here is to use an array populated by a variable that holds the current post category/categories.

    I must be missing something. 😉 Thanks in advance for helping me with this.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.