Actually I use the Custom Field Suite plugin to achieve that.
But I prefer the flexibility of yours 😉 and the UI in the post admin.
And I try to achieve what I did with CFS : display a random post in another one by fields comparison. That means I get the posts from a certain category which have a field value equal to the same field of the current post.
This is actually what I do :
$product = simple_fields_get_post_value(get_the_id(), array(1, 1), true); // get the field value for "Produit associé" global $post; $args = array( 'numberposts' => 1, 'category' => 46, 'meta_query' => array( array( 'key' => 'Produit associé', 'value' => $product, 'compare' => '=' ) ), 'orderby' => 'rand' ); $usecases = get_posts( $args ); foreach( $usecases as $post ) : setup_postdata($post);
But the combination of key and value doesn’t seem to work and, as you advice, I’d like to use IDs instead of names.
Thanks a lot for your help !
- The topic ‘[Plugin: Simple Fields] Compare fields between posts’ is closed to new replies.