Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress Custom Fields

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28225
    realph
    Participant

    Hey there,

    I’m not too familiar with PHP and the Custom Fields in WordPress but I wanted to give something a go.

    I write a few articles on my site and sometimes use other sites as a source for stories, I always link back to them (as you do) at the bottom of the article (below).

    [attachment=2]source_bottom.jpg[/attachment]
    What I’d love to do is add a custom field called "source" and throw the source link in the value (below).

    [attachment=1]customfield.jpg[/attachment]
    Doing this I’d like it to create a button at the top of the article like this (below).

    [attachment=0]source-top.jpg[/attachment]
    With it linking to the article I threw in the Custom Field value earlier.

    Now I’ve managed to make this work to an extent, check it out here: http://bitthirsty.com/battlefield-bad-c … wwii-level

    The problem is that it appears on every article, even the ones that don’t have a source attached to it. I’d like it to only appear on the articles where I’ve set a source in the Custom Field, could anyone help me solve this.

    This is the PHP I’m using for the button, like I said I don’t know much about PHP so sorry if it makes no sense whatsoever.

    Code:
    TheDoc
    Member

    From the Snippets section:

    Code:
    ID, ‘snippet-reference-URL’, true);

    if ($url) {
    echo “

    Reference URL“;
    }
    ?>

    #71836
    realph
    Participant
    "TheDoc" wrote:
    From the Snippets section:

    Code:
    ID, ‘snippet-reference-URL’, true);

    if ($url) {
    echo “

    Reference URL“;
    }
    ?>

    Thanks a bunch mate. Do you know why the p tag isn’t closed though?

    #71841
    TheDoc
    Member
    Quote:
    Thanks a bunch mate. Do you know why the p tag isn’t closed though?

    Oops! I’ll let Chris know!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.