RJP
RJP

Reputation: 5

Wordpress: if meta = true AND meta = true

I want to show a symbol as a separator between two meta fields but only when both are present — often only one will be in use, in which case I don't want to show the separator.

This is what I have at the moment:

<?php if ( get_post_meta($related->ID, 'author', true && $related->ID, 'photographer', true)) : ?>

I think the problem lies in the brackets but I've tried a ton of variations and can't get it to work. Can anyone point me in the right direction?

Upvotes: 0

Views: 130

Answers (1)

phpisuber01
phpisuber01

Reputation: 7715

You need to call the function twice to make this kind of comparison. The only thing that can be passed with a function are arguments.

<?php if ( get_post_meta($related->ID, 'author', true) && get_post_meta($related->ID, 'photographer', true)) : ?>

Upvotes: 1

Related Questions