Problem – link inexistent in multiple call for a post in 1 page
-
Hello ! First, I apologize if I am not clear on my problem as I am quite a beginner with wordpress or coding in general, and for my english if it’s weird, since I am French…
Here’s my problem:
I have a page on the site I’m working on which is used as a portfolio for an artist. (I use a modified version of the Gridsby theme by the way, made by modern themes.)I have on this page 4 categories that I call, the posts are showing up where they are supposed to, but the link to the post itself initialize only on the first appearance of the post.
For example if I have a post with the categories ‘sketches’ and ‘illustrations’, The thumbnail appear twice (which is what I want), both in the Sketches part and the Illustrations part, but the link of the post (to see the details) only works on the first thumbnails that appears.I am not sure if I am using the right code or if I am doing something wrong, and it has become quite urgent…
The code I am using on the correspondant PHP page:
<?php /** * Template Name: Fullwidth Gallery Page * * @package gridsby */ get_header(); ?> <div class="grid grid-pad"> <div class="col-1-1 content-wrapper"> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <section class="grid3d horizontal" id="grid3d"> <div class="grid-wrap"> <div class="sketches"> <h2>SKETCHES</h2> <div id="gallery-container" class="gridsby infinite-scroll"> <?php global $post; if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_time_method' ) ) ) : $args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'category_name' => 'Sketches', 'order' => 'ASC' ); else : $args = array( 'post_type' => 'post', 'posts_per_page' => -1 ); endif; $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <?php if ( has_post_format( 'image' )) { ?> <?php if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_link_method' ) ) ) : ?> <figure class="gallery-image"> <?php the_post_thumbnail('gridsby-gallery-thumb'); ?> </figure><!-- gallery-image --> <?php else : ?> <a href="<?php the_permalink(); ?>"> <figure class="gallery-image"> <?php the_post_thumbnail('gridsby-gallery-thumb'); ?> </figure><!-- gallery-image --> </a> <?php endif; ?> <?php } ?> <?php endforeach; ?> </div><!-- gallery-container --> </div> <div class="Concepts"> <h2>CONCEPTS</h2> <div id="gallery-container" class="gridsby infinite-scroll"> <?php global $post; if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_time_method' ) ) ) : $args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'category_name' => 'Concepts', 'order' => 'ASC' ); else : $args = array( 'post_type' => 'post', 'posts_per_page' => -1 ); endif; $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <?php if ( has_post_format( 'image' )) { ?> <?php if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_link_method' ) ) ) : ?> <figure class="gallery-image"> <?php the_post_thumbnail('gridsby-gallery-thumb'); ?> </figure><!-- gallery-image --> <?php else : ?> <a href="<?php the_permalink(); ?>"> <figure class="gallery-image"> <?php the_post_thumbnail('gridsby-gallery-thumb'); ?> </figure><!-- gallery-image --> </a> <?php endif; ?> <?php } ?> <?php endforeach; ?> </div><!-- gallery-container --> </div> <div class="ILLUSTRATIONS"> <h2>ILLUSTRATIONS</h2> <div id="gallery-container" class="gridsby infinite-scroll"> <?php global $post; if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_time_method' ) ) ) : $args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'category_name' => 'Illustrations', 'order' => 'ASC' ); else : $args = array( 'post_type' => 'post', 'posts_per_page' => -1 ); endif; $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <?php if ( has_post_format( 'image' )) { ?> <?php if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_link_method' ) ) ) : ?> <figure class="gallery-image"> <?php the_post_thumbnail('gridsby-gallery-thumb'); ?> </figure><!-- gallery-image --> <?php else : ?> <a href="<?php the_permalink(); ?>"> <figure class="gallery-image"> <?php the_post_thumbnail('gridsby-gallery-thumb'); ?> </figure><!-- gallery-image --> </a> <?php endif; ?> <?php } ?> <?php endforeach; ?> </div><!-- gallery-container --> </div> <div class="WIP"> <h2>Work In Progress</h2> <div id="gallery-container" class="gridsby infinite-scroll"> <?php global $post; if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_time_method' ) ) ) : $args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'category_name' => 'WIP', 'order' => 'ASC' ); else : $args = array( 'post_type' => 'post', 'posts_per_page' => -1 ); endif; $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <?php if ( has_post_format( 'image' )) { ?> <?php if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_link_method' ) ) ) : ?> <figure class="gallery-image"> <?php the_post_thumbnail('gridsby-gallery-thumb'); ?> </figure><!-- gallery-image --> <?php else : ?> <a href="<?php the_permalink(); ?>"> <figure class="gallery-image"> <?php the_post_thumbnail('gridsby-gallery-thumb'); ?> </figure><!-- gallery-image --> </a> <?php endif; ?> <?php } ?> <?php endforeach; ?> </div><!-- gallery-container --> </div> </div><!-- /grid-wrap --> <div class="content"> <?php global $post; if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_time_method' ) ) ) : $args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'order' => 'ASC' ); else : $args = array( 'post_type' => 'post', 'posts_per_page' => -1 ); endif; $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <?php if ( has_post_format( 'image' )) { ?> <?php if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_link_method' ) ) ) : ?> <div> <div class="lightbox-content"> <h2 class="dummy-title"><?php the_title(); ?><div class='share-button share-button-left'></div></h2> <?php the_content(); ?> </div> </div> <?php else : ?> <?php endif; ?> <?php } ?> <?php endforeach; ?> <span class="loading"></span> <span class="icon close-content"><i class="fa fa-close"></i></span> </div><!-- content --> </section><!-- grid3d --> </main><!-- #main --> </div><!-- #primary --> </div> </div> <?php get_footer(); ?>
- The topic ‘Problem – link inexistent in multiple call for a post in 1 page’ is closed to new replies.