If statement to check if more than one image attached

Community Forums Forums Design Tips and Tricks If statement to check if more than one image attached

This topic is: resolved

This topic contains 2 replies, has 1 voice, and was last updated by  alex2k5 1 year, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #17072

    alex2k5
    Participant
    Post count: 28

    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

    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    • This topic was modified 1 year, 9 months ago by  alex2k5.
    #17081

    alex2k5
    Participant
    Post count: 28

    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';
    }
    }
    }

    #17147

    alex2k5
    Participant
    Post count: 28

    I got this sorted, thanks.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.