• Resolved rudtek2

    (@rudtek2)


    I’m creating a site that links doctors to locations.
    I have a ACF field in my custom doctor post-type.

    I’m trying to link back on the locations list page to show the doctors that are using the certain location as their offices.

    when I set the plugin to permalinks, I can get the desired results. Doctors pages show the locations i chose for them, and the location single pages show the doctors that chose to work at those locations. I cannot get this to work on the list page though (main locations page). Where would i go to edit the code do do this. Is there a wordpress loop anywhere?

    this is the code i need injected into the list page:

    $doctors = get_posts(array(
    	'post_type' => 'team_member',
    	'meta_query' => array(
    		array(
    			'key' => 'relational_relationship',
    			'value' => '"' . get_the_ID() . '"',
    			'compare' => 'LIKE'
    		)
    	)
    ));
    
    if( $doctors ):
    	$doclink='<ul>';
    	foreach( $doctors as $doctor ):
    	$doclink.='<li><a href="'.get_permalink( $doctor->ID ).'">'.get_the_title( $doctor->ID ).'</a></li>';
    	endforeach;
    	$doclink.='</ul>';
    else:
    $doclink='no doctors at this location';
    endif;

    https://wordpress.org/plugins/wp-store-locator/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    If I understand correctly, then this filter will help you get what you want.

    You can add the doctor data under for example ‘doctors’, and then use this filter to show it in the search result template.

    If you decided to add the doctor data under the ‘doctors’ key, then you can access it under the same key in the template. So in the wpsl_listing_template usage example, you can replace ‘my_textinput’ with ‘doctors’ to make it show up.

    If that somehow doesn’t work, then you should first make sure the data is include in the ajax response. You can do this in a tool like Firebug, or any other browser webdevtool.

    Can you have a “search result template” for different categories?

    From the WP Store Locator interface, I want to return standard mapped results, but I also want to return all the locations in the “online” category in a custom result to just show the image, and name with a url to the website entered in WP Store Locator. Is this possible?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘adding data from custom post type’ is closed to new replies.