• Resolved djdoc

    (@djdoc)


    Hi,

    I am having an issue on my page that I am not sure why it happens.
    I created a custom search page that does the job pretty nicely (from code I found and added it some css classes).
    My issue is – when we stand on the “read more” of the second item and all the ones after it we get the link of the first one. This doesn’t happen in the title, just in the read more buttons.

    I would love to get your help.

    Here is the code so you can take a look at it:

    <div id="main-content">
    	<div class="searchpage container">
    		<div id="content-area" class="<?php extra_sidebar_class(); ?> clearfix">
    			<div class="et_pb_extra_column_main">
    				<?php if ( is_search() ) { ?>
    					<h1><?php printf( esc_html__( 'Search Results for: %s', 'extra' ), get_search_query() ); ?></h1>
    				<?php } else if ( is_archive() && have_posts() ) { ?>
    					<h1><?php the_archive_title(); ?></h1>
    				<?php } ?>
    
    				<?php if ( is_extra_tax_layout() ) { ?>
    					<?php extra_tax_layout(); ?>
    				<?php } else { ?>
    					<?php require locate_template( 'index-content.php' ); ?>
    				<?php } ?>
    			</div>
    			<?php echo do_shortcode('[et_pb_section global_module="1379"][/et_pb_section]'); ?>
    
    		</div> <!-- #content-area -->
    	</div> <!-- .container -->
    </div> <!-- #main-content -->
    • This topic was modified 5 years ago by bcworkz. Reason: code fixed

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

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

    (@lcf)

    just a thought. Is the code for “read more” button is in the same loop of search result query?

    Thread Starter djdoc

    (@djdoc)

    I guess it should be but I have no idea where it is.
    Any help?

    Moderator bcworkz

    (@bcworkz)

    The loop code is not in your posted code. Maybe in ‘index-content.php’?

    Usually the links for the current post are determined by get_permalink(), which relies upon the global $post variable to determine the current post. If your loop is driven by a different method that does not update $post, the observed behavior can result. Your more button link needs to be compatible with how your loop is driven, or your loop needs to be consistent with the standard WP loop so that $post is properly updated.

    When you post code in these forums, please demarcate with backticks or use the “code” button. When you don’t do so, the forum’s parser corrupts your code, making unusable for testing or copying for use. I fixed your OP code for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom search page issue’ is closed to new replies.