[wd_asp elements=’search’ ratio=’100%’ id=1]

(Daves Live Search Plugin) Add Category to results

26th January 2014

Wordpress - Miscellaneous

wordpress category

To show the category

1. Enable Author in the admin panel of the plugin by ticking the box. (Display Metadata, Display author & date for every search result)

2. Stop Date from showing With a bit of CSS tweaking, you should be there. Add this to your css.

.daves-wordpress-live-search_date {
display: none;
}

3. Replace below code in plugins\daves-wordpress-live-search\class-daves-wordpress-live-search-results.php
Compare what you have in class-daves-wordpress-live-search-results.php with code below. Paste this after if ( $displayPostMeta ) {
All the way up to $post->post_author_nicename = $dog; Maybe replace the $dog or what ever you have!


if ( $displayPostMeta ) {
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxx Codehaven CODE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$post = $wp_query->post;
$dog=$post->ID;

$category = get_the_category( $dog );
$dog = $category[0]->cat_name;

$dog = get_cat_ID( $dog ); //show cat id number from its name like "Tricks" (child)

foreach (get_the_category() as $cat) { // yay shows parent category for each $dog there is
$parent = get_category($cat->category_parent);
$dog = $parent->cat_name;
}

$authorName = get_the_author_meta( 'user_nicename', $post->post_author );
$authorName = apply_filters( 'dwls_author_name', $authorName );
$post->post_author_nicename = $dog;
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxx Codehaven CODE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx