• Resolved davewoods100

    (@davewoods100)


    Any help would be greatly appreciated as I’ve been trying to figure this out for a few hours.

    Basically, I’m trying to output a list of titles from of a specific post type based on whenever the “Style & Art” select box has been chosen within those posts.

    The below code doesn’t seem to output anything other than the opening and closing ul tags.

    However, if I remove the meta_query array then it lists all post types.

    <ul>
    	<?php
    	$args = array(
    		'post_type' => 'profiles',
    	    'meta_query' => array(
    	        array(
    	            'key' => 'you_may_also_like',
    	            'value' => 'Style & Art'
    	        )
    	    )
    	);
    
    	query_posts($args);
    
    	while ( have_posts() ) : the_post();
    	    echo '<li>';
    	    the_title();
    	    echo '</li>';
    	endwhile;
    
    	wp_reset_query();
    	?>
    </ul>

    I need to be able to filter them based on a certain criteria but not having any luck at the moment.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Could be the & in the ‘value’ parameter is the problem. Could you set up a test with a ‘value’ that did not contain the &. Could be the & is stored as
    “& amp;” (without the space) in the database.

    Thread Starter davewoods100

    (@davewoods100)

    Hi Lorro,

    Thanks for the feedback. Yeah I’d already considered that unfortunately and tried it without the ‘&’ in the value but didn’t have much luck.

    However, I did investigate this further and figured out that the value being returned was the “Term ID” and not the title of the category.

    So I swapped out the value for the ID of the category and it’s all working fine now thanks ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List posts when custom field is specific value’ is closed to new replies.