Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter the_briny

    (@the_briny)

    Wanted to update with my fix. It took me a while, but I tracked down the source of my unwanted change to the functions file (not the stylesheets as I had imagined). So I copy and pasted the code pertaining to featured images from the previous update’s functions file into my child theme. Here’s what that bit looks like, for the curious:

    // for displaying featured images
    	if( ! function_exists( 'ct_apex_featured_image' ) ) {
    	        function ct_apex_featured_image() {
    
    	                // get post object
    	                global $post;
    
    	                // default to no featured image
    	                $has_image = false;
    
    	                // establish featured image var
    	                $featured_image = '';
    
    	                // if post has an image
    	                if ( has_post_thumbnail( $post->ID ) ) {
    
    	                        // get the featured image ID
    	                        $image_id = get_post_thumbnail_id( $post->ID );
    
    	                        // get the image's alt text
    	                        $image_alt_text = get_post_meta($image_id, '_wp_attachment_image_alt', true);
    
    	                        // get the full-size version of the image
    	                        $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
    
    	                        // set $image = the url
    	                        $image     = $image[0];
    
    	                        // if alt text is empty, nothing else equal to title string
    	                        $title = empty($image_alt_text) ? '' : "title='" . esc_attr( $image_alt_text ) . "'";
    
    	                        // set to true
    	                        $has_image = true;
    	                }
    	                if ( $has_image == true ) {
    
    	                        // on posts/pages display the featured image
    	                        if ( is_singular() ) {
    	                                $featured_image = "<div class='featured-image' style=\"background-image: url('" . esc_url( $image ) . "')\" $title></div>";
    	                        } // on blog/archives display with a link
    	                        else {
    	                                $featured_image = "
    	                <div class='featured-image' style=\"background-image: url('" . esc_url( $image ) . "')\" $title>
    	                    <a href='" . get_permalink() . "'>" . get_the_title() . "</a>
    	                </div>
    	                ";
    	                        }
    	                }
    
    	                // allow videos to be added
    	                $featured_image = apply_filters( 'ct_apex_featured_image', $featured_image );
    
    	                if( $featured_image ) {
    	                        echo $featured_image;
    	                }
    	        }
    	}
    Thread Starter the_briny

    (@the_briny)

    Thanks for piping in, too, CrouchingBruin.

    Thread Starter the_briny

    (@the_briny)

    That’s exactly what I needed! Thanks so much, Ben, for your quick response and detailed explanation.

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