Home Forums Free Themes Photo Perfect Main page photo links to blog post instead of enlarging photo!


Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #22246


    I’ve asked this question before but I’m having issues with it again. I updated my theme and I can’t figure out how to change it back. Could you do me a favour and copy and paste the exact text that would be replaced in content masonary?



    Image thumbnails comes with two icons overlay for image enlarge ( eye icon) and for post link (anchor icon). Hope this is what you are looking for.


    I want the code to put in that changes the image on the main page from enlarging and instead just goes into the blog post. When people click on the image on the main page I want it to bring them into the post not enlarge the image. I need the coding to write under the masonary template in the editor. I had the code before but when I updated it reverted back. Thanks.



    We are sorry that your changes were reverted back after the update, but if you make changes on the parent theme it will always be reverted on the update.

    We will provide you a method with which you can keep your changes safe.

    First of all you will have to create a child theme for theme theme you are using currently. You can make the child theme manually or use a certain plugin like https://wordpress.org/plugins/wp-child-theme-generator/ to create a child theme.

    Now after you have created the child theme, you will have to make a template-parts folder inside the child theme.

    After you have created the template-parts folder, create a file named content-masonry.php inside the template-parts folder.

    Now open the content-masonry.php file and inside it paste the below given code

     * Template part for displaying posts in masonry.
     * @link https://codex.wordpress.org/Template_Hierarchy
     * @package Photo_Perfect
    <article id="post-<?php the_ID(); ?>" <?php post_class( 'masonry-entry' ); ?>>
    	$featured_image_full_url = '';
    	if ( has_post_thumbnail() ) {
    		$featured_image_full_url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
      <div class="masonry-thumbnail post-item">
    		<?php if ( has_post_thumbnail() ) :  ?>
            <a href="<?php the_permalink();?>" class="post-thumb">
    			<?php the_post_thumbnail( 'large' ); ?>
    		<?php else : ?>
    			$no_image_url = '';
    			$random_number = rand( 1, 2 );
    			$no_image_url = get_template_directory_uri() . '/images/no-image-'. esc_attr( $random_number ). '.png';
            <a href="<?php the_permalink(); ?>" class="post-thumb">
              <img src="<?php echo esc_url( $no_image_url );?>" alt="<?php the_title_attribute(); ?>" />
    		<?php endif ?>
        <div class="post-content">
    			<?php if ( ! empty( $featured_image_full_url ) ) :  ?>
            <a href="<?php echo esc_url( $featured_image_full_url ); ?>" class="popup-link"><i class="fa fa-eye"></i></a>
    			<?php endif ?>
          <a href="<?php the_permalink(); ?>"><i class="fa fa-link"></i></a>
          <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
      </div><!-- .masonry-thumbnail -->
    </article><!-- #post-## -->

    Now you have a child theme with the changes you want.
    Similarly, you can also override other templates and functions via child theme.

    Hope it helps.
    Best regards.


    It worked! Thanks so much!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.