• 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

If statement to check if more than one image attached

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 › If statement to check if more than one image attached

This topic is: resolved

Tagged: attachments, gallery, images

  • This topic has 2 replies, 1 voice, and was last updated 12 years, 5 months ago by alex2k5.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • February 1, 2013 at 10:27 am #17072
    alex2k5
    Participant

    I am looking to run something if there is more than one attachment on a post, on the full post page only. I am attempting to run this code, but every time it executes all PHP processing stops, the rest of content, sidebars, footer do not load. No error messages are returned.

    add_action('genesis_after_post_content','gogallery', 0) ;
    function gogallery() {
    if (is_singular()) {
    $attachments34 = get_children(
    array(
    'post_type' => 'attachment',
    'post_parent' => $post->ID
    )
    );
    if(count($attachments34) > 1) {
    echo 'hello';
    }
    }
    }

    Is there a Genesis specific way to do this?

    Thanks

    February 1, 2013 at 10:35 am #17081
    alex2k5
    Participant

    Code isn't parsing correctly, will try again.

    add_action('genesis_after_post_content','gogallery', 0) ;
    function gogallery() {
    if (is_singular()) {
    $attachments34 = get_children(
    array(
    'post_type' => 'attachment',
    'post_parent' => $post->ID
    ));
    if(count($attachments34) > 1) {
    echo 'hello';
    }
    }
    }

    February 1, 2013 at 1:47 pm #17147
    alex2k5
    Participant

    I got this sorted, thanks.

  • 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

© 2025 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