• Resolved mosabua

    (@mosabua)


    Hi

    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

    https://wordpress.org/plugins/stellar-places/

Viewing 2 replies - 1 through 2 (of 2 total)
  • @mosabua,

    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.

    Thread Starter mosabua

    (@mosabua)

    Hi Micah,

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

    werner

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