Skip to content

Instantly share code, notes, and snippets.

@kprajapatii
Created October 17, 2016 04:35
Show Gist options
  • Save kprajapatii/b58e4a761bae886701256669799e148d to your computer and use it in GitHub Desktop.
Save kprajapatii/b58e4a761bae886701256669799e148d to your computer and use it in GitHub Desktop.
Display listing author on GeoDirectory listing pages.
<?php // YOU MOST LIKELY DON'T NEED THIS LINE, SO DON'T COPY PASTE THIS LINE WITH BELOW CODE
/***** CODE STARTS HERE *****/
// Display listing author on listing pages.
function geodirectory_author_link_on_listings_page( $post ) {
if ( !empty( $post ) && !empty( $post->post_author ) && geodir_is_page( 'listing' ) ) {
$author_link = get_author_posts_url( $post->post_author );
$author_link = geodir_getlink( $author_link, array( 'geodir_dashbord' => 'true', 'stype' => $post->post_type ), false );
echo '<div style="clear:both;" class="geodir_more_info geodir-author-link"><i class="fa fa-user"></i> <span>' . __( 'Author:', 'geodirectory' ) . '</span> <a href="' . $author_link . '">' . get_the_author() . '</a></div>';
}
}
add_action( 'geodir_before_listing_post_excerpt', 'geodirectory_author_link_on_listings_page', 10, 1 );
/***** CODE ENDS HERE *****/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment