• Resolved kasperbs

    (@kasperbs)


    Hi I’m rading through a series of tutorials on how to use WordPress Custom Fields. It is maybe a little bit over my standard, as my PHP knowledge is pretty limited. This is from the website, but could anyone explain a bit more in depth, whats going on so I can google my way to the rest.

    From the website: https://justintadlock.com/archives/2007/10/16/using-wordpress-custom-fields-subtitles

    The CODE
    //

    $subtitle = get_post_meta
    ($post->ID, 'subtitle', $single = true);
    if($subtitle !== '') echo ': ' . $subtitle;

    //

    The explanation from the site:

    “This code pulls your custom field key of “subtitle” out and displays it on whatever pages have a subtitle.”

    please elaborate and in PHP language explain what the different things mean.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter kasperbs

    (@kasperbs)

    By doing my own research I now understand how to use this.

    I guess it was the if statement that I didn’t really knew how to use. And the (not equal to) also confused me a bit.

    Basically the not equal too part of the code checks that the custom field has a value before echoing it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Please explain these three lines for me’ is closed to new replies.