• Resolved chavalu

    (@chavalu)


    The theme I’m using has a default featured image which shows on posts, but it’s not showing up to the custom post type.

    I think I need to add something to this line of code, but I don’t know what.
    Can you please help me?

    if ( $add_single_image && $image && is_singular( ‘post’ ) ) {
    printf( ‘<div class=”single-featured-image”>%s</div>’, $image ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped — low risk, and Genesis does not escape image output either.
    }

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not quite sure what you’re going to need here to get featured images showing for your post type in question, as that’s more a theme question than CPTUI. If you’re able to set the featured images already for your posts in the post type, then CPTUI’s hand in things is already covered. Now it’s more a question for the Genesis child theme you’re using and what needs to be done with that.

    Thread Starter chavalu

    (@chavalu)

    Well my question is somewhat contained. Just like we’d call posts as ‘post’ in php, how would I call the cptui?

    Thank you!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    That’s the thing though, we don’t really have any custom frontend/template/theme functionality specific to CPTUI. So I’m confused by “How would I call the cptui” part. Closest I can infer based on what’s already provided, would be maybe this:

    if (
        $add_single_image &&
        $image &&
        (
            is_singular( ‘post’ ) || is_singular( 'my-post-type-slug' )
        )
    )
    {
    

    I put on their own lines for clarity in reading. The “my-post-type-slug” part is what you’d want to change to match the post type you registered. You’d repeat that as needed for any others you’re wanting affected here.

    Thread Starter chavalu

    (@chavalu)

    That was super helpful- with a bit of tweaking I got it.

    THANK YOU so much!!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add featured image to custom post type’ is closed to new replies.