I am a bit confused, but when I call get_post_meta(get_the_ID(), "event", $single = true); it returns the worthiness for your key, but when I refer to it as by doing this:

$event_page_meta = "event";

function isEvent()
    return get_post_meta(get_the_ID(), $event_page_meta, $single = true);

it returns Variety of all meta. I am rather unexperienced php-developer (mostly python), however i cannot use whatever distinction between individuals two calls.

Are you able to explain why I am unable to extract that answer to a flexible?

Two problems:

  1. The 3rd argument for get_publish_meta ought to be true or false, not really a variable assignment. Just write true.

  2. $event_page_meta isn't in scope inside the function, you can either have to pass it in being an argument or allow it to be global.


function isEvent($event_page_meta) {
    return get_post_meta(get_the_ID(), $event_page_meta, true);

//somewhere else
$something = isEvent($event_page_meta);


function isEvent() {
    global $event_page_meta;
    return get_post_meta(get_the_ID(), $event_page_meta, true);

...this assumes $event_page_meta consists of the title from the metadata key you need to retrieve. I don't know why it's inside a variable and not simply a string inside your function call.