Forums

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

Home Forums Back End Default image in custom field

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #33580
    Rai
    Member

    Hello guys,

    I´m looking for a solution to have a default image when this custom field (wordpress) it is not in use.

    	 '/>

    Any idea?
    Many thanks.
    Rai.

    #83693
    TheDoc
    Member
    
    $img = get_post_meta($post->ID, 'imagen', true);

    if ($img) {
    echo '';
    } else {
    echo '';
    }
    ?>
    #83712
    Rai
    Member

    Thanks Doc,

    But it show me this error:

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/content/57/6689957/html/azahararomaterapia/wp-content/themes/azahar/pagina-producto.php on line 19
    #83716
    TheDoc
    Member

    Oops! Terrible copy/pasting!

    
    $img = get_post_meta($post->ID, 'imagen', true);

    if ($img) {
    echo '';
    } else {
    echo '';
    }
    ?>

    Give that a go!

    #83717
    Rai
    Member

    Excellent Doc!,

    Can you recommend something to read to learn the code at that level?.

    Thanks.

    #83718
    TheDoc
    Member

    That was actually just a modified version of a snippet from this very site! https://css-tricks.com/snippets/wordpress/using-custom-fields/

    As far as suggestions on where to learn, I don’t really have any. It’s just repetition, practice practice practice.

    Try to not take on too much at once or else none of it will stick. Focus on a few features at a time and really try to master them before you move on to something else.

    #83769
    Rai
    Member

    Thanks Doc!.

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