Show Linked Post in Whoop Listings
This topic contains 12 replies, has 3 voices, and was last updated by Giri 8 years ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
March 13, 2017 at 12:14 pm #366947
Hi Guys,
If an event has a linked post (the venue), I would like to display that in the Listing/Search results and in the whoop_event_detail_after_category area.
I have tried putting the geodir_cpt_link_display_link_business function in the themes events.php file but no result.
I have attached 2 images of where I’m trying to get the link to appear. Would you be able to take a look please.
Regards
JamesMarch 13, 2017 at 10:23 pm #367062Hi James,
I alerted the developers about your question. They’ll let you know asap.
Thanks
March 14, 2017 at 3:13 pm #367230Hi James,
can you post your wp admin and ftp details?
Thanks
March 14, 2017 at 3:45 pm #367244This reply has been marked as private.March 14, 2017 at 5:17 pm #367264Thanks James. Give me some time.
I’ll let you know once i’m done.
Thanks
March 14, 2017 at 6:05 pm #367287Hi James,
Your child theme functions.php file is not writable.
So I installed code snippets plugin and added the following code.
function whoop_event_detail_venue() { ?> <dl> <dt> <?php echo __('Venue:', GEODIRECTORY_FRAMEWORK); ?> </dt> <dd class="eve-dates"> <?php do_action('whoop_event_detail_venue_link'); ?> </dd> </dl> <?php } add_action('whoop_event_detail_after_category', 'whoop_event_detail_venue'); add_action( 'whoop_event_detail_venue_link', 'whoop_geodir_event_display_link_business' ); function whoop_event_listing_venue($view, $post) { if ($view != 'listview') { return; } if ($post->post_type != 'gd_event') { return; } ?> <div> <span> <?php echo __('Venue:', GEODIRECTORY_FRAMEWORK); ?> </span> <?php do_action('whoop_event_listing_venue_link'); ?> </div> <?php } add_action('geodir_after_listing_post_title', 'whoop_event_listing_venue', 0, 2); add_action( 'whoop_event_listing_venue_link', 'whoop_geodir_event_display_link_business' ); function whoop_geodir_event_display_link_business() { global $post; $post_type = geodir_get_current_posttype(); $all_postypes = geodir_get_posttypes(); if ( !empty( $post ) && $post_type == 'gd_event' && (geodir_is_page( 'detail' ) || geodir_is_page( 'listing' ))&& isset( $post->geodir_link_business ) && !empty( $post->geodir_link_business ) ) { $linked_post_id = $post->geodir_link_business; $linked_post_info = get_post($linked_post_id); if( !empty( $linked_post_info ) ) { $linked_post_type_info = in_array( $linked_post_info->post_type, $all_postypes ) ? geodir_get_posttype_info( $linked_post_info->post_type ) : array(); if( !empty( $linked_post_type_info ) ) { $linked_post_title = !empty( $linked_post_info->post_title ) ? $linked_post_info->post_title : __( 'Listing', 'geodirevents' ); $linked_post_url = get_permalink($linked_post_id); $html_link_business = '<a title="' . esc_attr( $linked_post_title ) . '" href="'.$linked_post_url.'">' . wp_sprintf( __( '%s', 'geodirevents' ), $linked_post_title ) . '</a>'; echo apply_filters( 'whoop_geodir_more_info_link_business', $html_link_business, $linked_post_id, $linked_post_url ); } } } }
You have added a Venue part in detail page already. Please remove that part. I have used a hook to add the code.
Thanks.
March 14, 2017 at 6:06 pm #367289This reply has been marked as private.March 14, 2017 at 6:49 pm #367301Wow thats excellent, thank you!
I have noticed that the the code doesn’t hook onto the “All Whats On?” section that can be found on the home page. I’m using your GD > Event Listing Widget to display.
Can this be hooked into that?
Thank you again!
March 15, 2017 at 8:47 am #367412Hi James,
Fixed that in your site.
Here is the modified code.
function whoop_event_detail_venue() { ?> <dl> <dt> <?php echo __('Venue:', GEODIRECTORY_FRAMEWORK); ?> </dt> <dd class="eve-dates"> <?php do_action('whoop_event_detail_venue_link'); ?> </dd> </dl> <?php } add_action('whoop_event_detail_after_category', 'whoop_event_detail_venue'); add_action( 'whoop_event_detail_venue_link', 'whoop_geodir_event_display_link_business' ); function whoop_event_listing_venue($view, $post) { if ($view != 'listview') { return; } if ($post->post_type != 'gd_event') { return; } ?> <div> <span> <?php echo __('Venue:', GEODIRECTORY_FRAMEWORK); ?> </span> <?php do_action('whoop_event_listing_venue_link'); ?> </div> <?php } add_action('geodir_after_listing_post_title', 'whoop_event_listing_venue', 0, 2); add_action( 'whoop_event_listing_venue_link', 'whoop_geodir_event_display_link_business' ); function whoop_geodir_event_display_link_business() { global $post; $post_type = $post->post_type; $all_postypes = geodir_get_posttypes(); if ( !empty( $post ) && $post_type == 'gd_event' && isset( $post->geodir_link_business ) && !empty( $post->geodir_link_business ) ) { $linked_post_id = $post->geodir_link_business; $linked_post_info = get_post($linked_post_id); if( !empty( $linked_post_info ) ) { $linked_post_type_info = in_array( $linked_post_info->post_type, $all_postypes ) ? geodir_get_posttype_info( $linked_post_info->post_type ) : array(); if( !empty( $linked_post_type_info ) ) { $linked_post_title = !empty( $linked_post_info->post_title ) ? $linked_post_info->post_title : __( 'Listing', 'geodirevents' ); $linked_post_url = get_permalink($linked_post_id); $html_link_business = '<a title="' . esc_attr( $linked_post_title ) . '" href="'.$linked_post_url.'">' . wp_sprintf( __( '%s', 'geodirevents' ), $linked_post_title ) . '</a>'; echo apply_filters( 'whoop_geodir_more_info_link_business', $html_link_business, $linked_post_id, $linked_post_url ); } } } }
Thanks
March 15, 2017 at 11:56 am #367439Perfect thank you! Exactly as I wanted!
March 15, 2017 at 11:57 am #367440You are welcome 🙂
March 15, 2017 at 12:02 pm #367441This reply has been marked as private.March 15, 2017 at 12:32 pm #367445This reply has been marked as private. -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket