• Windurin

    (@windurin)


    Hi,

    I’m using the Lite version of the plugin but I noticed this snippet here which says it will let you show the post type name in either the title or the content areas of the Results:

    https://knowledgebase.ajaxsearchpro.com/miscellaneous/post-types/showing-the-post-type-name-in-result-title

    Neither snippet seems to be working though, the results just show as the default title and content. Is the snippet out of date, like the name of the hook changed in an update perhaps, or does it only work on the Pro version? Any help would be appreciated.

    I tried adding both versions of the snippet using the Code Snippets plugin. Thanks.

    • This topic was modified 3 years ago by Windurin. Reason: typo
Viewing 1 replies (of 1 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi,

    That one is only works with the Pro version. Try this instead:

    add_filter( 'asl_results', 'asl_show_the_post_type_title', 10, 1 );
    function asl_show_the_post_type_title( $results ) {
      foreach ($results as $k=>&$r) {
    		if ( isset($r->post_type) ) {
    			// Modify the post title
    			$post_type_obj = get_post_type_object( $r->post_type );
    			$r->title = $post_type_obj->labels->singular_name . ' - ' . $r->title;
    		}
      }
    
      return $results;
    }

    Best,
    Ernest M.

Viewing 1 replies (of 1 total)
  • The topic ‘Show Post Type Name in Results Title’ is closed to new replies.