• how to post list of all title post on sidebar and highlight current post title in single page using wp-query just check my code below and help me to highlight current post title

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. Also the <ul> messes with the formatting of the post here. ]

    <div class="right">
    
    <ul>
    			        	    <li style="border-bottom: 1px solid black;"><strong>SERVICES OFFERED</strong>
    			        	    <?php $args = array( 'post_type' => 'services', 'posts_per_page' => 10,
      'order'=>'DESC');
    $loop = new WP_Query( $args );
    if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();?> 
    
    <li><a>" style="color:black;"><?php the_title() ?></a></li>
    				        	        <?php endwhile; ?>
     <?php endif; ?>
    			        	        </ul>

    https://www.ads-software.com/extend/plugins/wordpress/

Viewing 1 replies (of 1 total)
  • Thread Starter kiran kola

    (@kola-kiran)

    I resolved it

    here is the code

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <ul class="servcslst" style="margin-bottom:50px;" >
     <li style="border-bottom: 1px solid black;"><strong style="">SERVICES OFFERED
        <?php
    
             $args = array(
    	'posts_per_page'  => 100,
    	'numberposts'     => 100,
    	'orderby'         => 'menu_order',
    	'order'           => 'ASC',
    	'post_type'       => 'services',
    	'post_status'     => 'publish'
    	 );
    
            $lastposts = get_posts($args);
    
            foreach($lastposts as $post) :
            setup_postdata($post); ?>
    
            <li<?php if ( $post->ID == $wp_query->post->ID ) { echo ' id="current"'; } else {} ?>>
    
                <a>"><?php the_title(); ?></a>
    
        <?php endforeach; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Highlight my current post title’ is closed to new replies.