Show Linked Post in Whoop Listings

This topic contains 12 replies, has 3 voices, and was last updated by  Giri 7 years, 2 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #366947

    James Stevenson
    Expired Member
    Post count: 21

    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
    James

    #367062

    Paolo
    Site Admin
    Post count: 31206

    Hi James,

    I alerted the developers about your question. They’ll let you know asap.

    Thanks

    #367230

    Giri
    Expired Member
    Post count: 3155

    Hi James,

    can you post your wp admin and ftp details?

    Thanks

    #367244

    James Stevenson
    Expired Member
    Post count: 21
    This reply has been marked as private.
    #367264

    Giri
    Expired Member
    Post count: 3155

    Thanks James. Give me some time.

    I’ll let you know once i’m done.

    Thanks

    #367287

    Giri
    Expired Member
    Post count: 3155

    Hi 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.

    #367289

    Giri
    Expired Member
    Post count: 3155
    This reply has been marked as private.
    #367301

    James Stevenson
    Expired Member
    Post count: 21

    Wow 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!

    #367412

    Giri
    Expired Member
    Post count: 3155

    Hi 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

    #367439

    James Stevenson
    Expired Member
    Post count: 21

    Perfect thank you! Exactly as I wanted!

    #367440

    Giri
    Expired Member
    Post count: 3155

    You are welcome 🙂

    #367441

    James Stevenson
    Expired Member
    Post count: 21
    This reply has been marked as private.
    #367445

    Giri
    Expired Member
    Post count: 3155
    This reply has been marked as private.
Viewing 13 posts - 1 through 13 (of 13 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket