• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Checking custom field exists; where did I make a mistake?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Checking custom field exists; where did I make a mistake?

This topic is: not resolved

Tagged: custom field

  • This topic has 2 replies, 2 voices, and was last updated 9 years, 10 months ago by lvvvvvl.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • July 20, 2016 at 10:03 pm #189879
    lvvvvvl
    Participant

    Hello,

    I've written a custom field to display a link back to the image authors website as per copyright laws.

    I want it to only apply on pages and posts, and only if the custom field has a value assigned to it. It works perfectly on Posts but not on Pages.

    When it's on a page, even one without a value assigned to that field, it automatically fills the value with the current pages url.

    This is my code:

    // Display Image Source
    add_action('genesis_entry_footer', 'image_source', 1 );
    function image_source() {
    if ( is_page() || is_single() && genesis_get_custom_field('imgsource') )
    echo '<div id="imagesource">Image Credit: <a href=" '. genesis_get_custom_field('imgsource') .'" target="_blank" rel="nofollow">Photo Artist</a></div>';
    }

    What have I done wrong?

    Thank you.

    July 21, 2016 at 1:47 am #189883
    Brad Dalton
    Participant

    Try

    if ( is_singular(array( 'post','page' ) ) )
    

    With this code


    Tutorials for StudioPress Themes.

    July 21, 2016 at 2:06 am #189887
    lvvvvvl
    Participant

    That was it, awesome! Thanks Brad.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble