i am facing a issue, on my wordpress site in left side i loaded post list with title and excerpt, and when you click on that content will get load on right side of page and its working fine
but i like to add active or current class when any link from list get clicked and open in side, and first one as active already as it is already displaying content on right side
please check code
on left side i am using
<?php
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'post', //Specyfying post type
'posts_per_page' => 10, //No. of posts to show
'paged' => $paged //For pagination
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
//To get ID of post
$id = get_the_ID();
$excerpt = get_the_excerpt();
$excerpt = substr( $excerpt , 0, 100);
?>
<article id="post-<?php the_ID(); ?>" class="et_blog_post" >
<div class="entry-content">
<h3 calss="entry-title" >
<a onclick="location.href='https://example.com/blog/?postid=<?php echo $id; ?>#post'" ><?php the_title(); ?></a></h3>
<div class="post-content"><div class="post-content-inner">
<p><?php echo $excerpt; ?></p></div>
<p><a onclick="location.href='https://example.com/blog/?postid=<?php echo $id; ?>#post'" class="blog-read-more" > READ MORE</a></p>
</div></div>
</article> <?php
endwhile;
?>
and on right side i am using
<?php
$post = $_GET['postid']; //Fetching value of postid from url
//To show post's content
$include = get_posts("include=$post");
$title = get_the_title();
$content = apply_filters('the_content',$include[0]->post_content);?>
<div class="entry-content">
<h1><?php echo get_the_title($post); ?></a></h1>
<p><?php echo $content; ?></p>
now issue is that i am want to add current or active class to article like class= "et_blog_post active" if current post is opened in right side for that i tried lot of solution that are provided here, i like to use url==href it add class but nothing working please suggest a solution thanks in advance and sorry for bad english