Support » Plugin: Stellar Places » Categories & custom fields in info-window.html

  • Resolved mosabua



    how can I add the loctaion categories and some custom fields generated with Advanced Custom Fields in the info-windows.html (in the single.php it works perfectly)

    My first guess was to use <%= stlr_location_categories %> and get_terms( ‘stlr_location_categories’ ); for the categories but sadly that didn’t work.

    The same applies for the ACF-Fields. I also tried the ACF-way of using the_field(‘place_gutschein’); instead of <%= place_gutschein %> but both didn’t work.

    Any clues?

    thanks werner

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Micah Wood



    Yes… the info-window.html template is not a PHP template, so any PHP code you add will be displayed, not run.

    The info-window.html template uses a JavaScript templating engine to replace the existing placeholders with the actual data. So, getting your data into the template is actually a two-part process:

    1. First, you need to ensure that the data is added to the Stellar_Place object that is passed to JavaScript for rendering.
    2. Second, you will need to ensure that the placeholder in the info-window.html template exists and uses the same name as the property that you added to the Stellar_Place object.

    To add your data to the Stellar_Place object just do something like this:

    add_filter( 'stellar_place', 'custom_stellar_place_data', 10, 2 );
    function custom_stellar_place_data( $place, $post ) {
    	$place->gutschein = get_field( 'place_gutschein', $post->ID );
    	return $place;

    Then, to add your placeholder in the info-window.html template, just do something like this:

    <%= gutschein %>

    NOTE: Be sure that you’ve copied the info-window.html template into a stellar-places directory in your active theme. This allows you to customize the template without losing those changes when updating the plugin. Ideally, you would do this in a child theme so you don’t lose these changes when you update your theme as well.

    Hi Micah,

    thanks for the code (and the awesome plugin) – works just perfect!


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Categories & custom fields in info-window.html’ is closed to new replies.