• I have an amended attachment page using a child theme. The image on the attachment page appears twice, and I cannot see why this is happening (it looks like it is a featured image on a post page along with the ‘normal’ image appearing below it).

    How can I edit the attachment.php page to remove the duplicate image? Below is the attachment.php

    
    <?php
    /**
     * The Template for displaying all single posts.
     *
     * @package GeneratePress
     */
     
    // No direct access, please
    if ( ! defined( 'ABSPATH' ) ) exit;
    
    get_header(); ?>
    
    	<div id="primary" <?php generate_content_class();?>>
    		<main id="main" <?php generate_main_class(); ?>>
    		<?php do_action('generate_before_main_content'); ?>
    		<?php while ( have_posts() ) : the_post(); ?>
    <?php echo wp_get_attachment_link( $attachment->ID, 'full'); ?>
    
    			<?php get_template_part( 'content', 'single' ); ?>
    <?php
    	if (function_exists('exifography_display_exif'))
    		echo exifography_display_exif();
    ?>
    			<?php
    				// If comments are open or we have at least one comment, load up the comment template
    				if ( comments_open() || '0' != get_comments_number() ) : ?>
    					<div class="comments-area">
    						<?php comments_template(); ?>
    					</div>
    			<?php endif; ?>
    
    		<?php endwhile; // end of the loop. ?>
    		<?php do_action('generate_after_main_content'); ?>
    		</main><!-- #main -->
    	</div><!-- #primary -->
    
    <?php 
    do_action('generate_sidebars');
    get_footer();
    

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • WHOA, number 1, go into Photoshop and make these images SMALLER 4592 × 3448 pixels is WAY TOO BIG and causes your site to LAG!

    Now for your question.
    In the header.php it calls the image @ full size as the header image.

    You will need to create a custom header for your attachment.php
    https://codex.ww.wp.xz.cn/Function_Reference/get_header

    In attachment.php you will call this new header-attachment.php on line 23
    php wp_head();
    with
    php wp_head(‘header-attachemnt’);

    that should do it!

    Thread Starter kdric

    (@kdric)

    Thanks for you reply – but, can you break it down into steps of what I need to do: I do not see what code I need to edit, and where the edits go….

    Sorry, above I said in wp_head(); but it is actually get_header(‘header-attachment);

    Follow the link above and experiment. You will have to copy the contents of header.php into a new file named header-attachment.php and remove the div that contains the header image. Then call that new header on the attachment.php file.

    If this sounds too much for you there are professionals who depend on people like you to feed their kids! Find a reliable web guy/gal and drop some cash in their pockets.

    Thread Starter kdric

    (@kdric)

    there are professionals who depend on people like you to feed their kids

    I’ve my own kids to feed: plus I like to learn how to do this…;)

    Ok then, clear instructions provided above!

    Good luck.

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

The topic ‘Editing attachment page’ is closed to new replies.