I am trying to display the post title if the custom field exists and has a value of apple…
<?php if ( isset ( get_post_meta($post->ID, 'mycustomvalue', true ) ) ) && if ( get_post_meta($post->ID, 'mycustomvalue', true ) == 'apple' ) : ?>
<?php the_title(); ?>
I am getting a white screen, anyone spot where I am going wrong?
You can hook into
the_title()
to alter the output.In functions.php paste this:
In your template, you can just use
<?php the_title(); ?>
To use your custom value in your template:
Because, in your code you didn’t close the IF condition.
I have modified your code but NOT tested.
NOTE: if you don’t want pass the third parameter, you will get the result as an array and you have to change your code from
!empty( $post_meta )
tocount( $post_meta ) > 0