• Resolved dpendleton

    (@dpendleton)


    Hi, I’ve tried to fix this issue myself, but am new to coding/php and haven’t managed to get it working. I’m using the SearchWP Live Ajax Search plugin and am trying to get it show the Category after the page title, rather than the post type. Here is the code:

    
    <?php if ( have_posts() ) : ?>
    	<?php while ( have_posts() ) : the_post(); ?>
    		<?php $post_type = get_post_type_object( get_post_type() ); ?>
    		<div class="searchwp-live-search-result" role="option" id="" aria-selected="false">
    			<p><a>">
    				<?php the_title(); ?> (<?php echo esc_html( $post_type->labels->singular_name ); ?>) &raquo;
    			</a></p>
    		</div>
    	<?php endwhile; ?>
    <?php else : ?>
    	<p class="searchwp-live-search-no-results" role="option">
    		<em><?php esc_html_x( 'No results found.', 'swplas' ); ?></em>
    	</p>
    <?php endif; ?>
    

    I understand it’s the <?php $post_type = get_post_type_object( get_post_type() ); ?> line I need to change (I think) and assume it’s get_category I would need to use? Just can’t figure out the syntax. Would appreciate any help!

    Thanks

    • This topic was modified 6 years, 11 months ago by Jan Dembowski.
    • This topic was modified 6 years, 11 months ago by Jan Dembowski. Reason: Fixed formatting
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help with a function’ is closed to new replies.