• Resolved nici-

    (@nici-2)


    Hiho,

    I tried to add a custom template – which seems to work with placing the code into the function.php:

    ******************
    add_filter( ‘wpsl_templates’, ‘custom_templates’ );

    function custom_templates( $templates ) {

    /**
    * The ‘id’ is for internal use and must be unique ( since 2.0 ).
    * The ‘name’ is used in the template dropdown on the settings page.
    * The ‘path’ points to the location of the custom template,
    * in this case the folder of your active theme.
    */
    $templates[] = array (
    ‘id’ => ‘hbdb’,
    ‘name’ => ‘Holzbaudatenbank’,
    ‘path’ => get_stylesheet_directory() . ‘/’ . ‘wpsl-templates/custom.php’,

    );

    return $templates;
    }
    *************

    So far fine.

    Then I tried to pull in the store excerpt – which failed.

    I started with the how-to for the post content. Only I can’t find out, WHERE to put the additional code. You say, only paste lines 26-28 _into the template_. So far fine, but WHERE inside the _template_ (I use the list unter map template)? I cant find the right place, with the template using “$output”, the code given using “$listing_template” to start with… Also anyway the template hasn’t a list of the included data fields but uses a/the class.

    So I had a look at the class to find that the it has several options regarding post content. However, though I have activated the more-link in the options, there is no more link…? So I already fail on having the post content and thus have nothing to change for post excerpt.

    And the question remains: Where/how can I edit the template to show the excerpt?

    Could you give me a hint as to sort the thing out? Thanks a lot!

    Best regards,
    nici-

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter nici-

    (@nici-2)

    Oh, I forgot – another thing:

    I’d like to define a special media size for the store locator list (or use the medium size instead of the thumbnails. How can I replace the thumbnail with one of the other media sizes like medium or medium_large or custom type in my template?

    And last not least, I forgot: I think store locator is a great thing, I really really like it. I’d go for Pro if there is one?

    Best regards,
    nici-

    Plugin Author Tijmen Smit

    (@tijmensmit)

    Can you add the code you have so far to a gist?

    How to change the media size is explained here.

    Thread Starter nici-

    (@nici-2)

    Dear Tilmen, thanks for your fast reply and your help!

    Actually I did not find out how to put Code into gist, so sorry. I try to put it here…

    What I did was:

    1.) Code in the function.php:

    ****snip ***

    add_filter( ‘wpsl_templates’, ‘custom_templates’ );

    function custom_templates( $templates ) {

    /**
    * The ‘id’ is for internal use and must be unique ( since 2.0 ).
    * The ‘name’ is used in the template dropdown on the settings page.
    * The ‘path’ points to the location of the custom template,
    * in this case the folder of your active theme.
    */
    $templates[] = array (
    ‘id’ => ‘hbdb’,
    ‘name’ => ‘Holzbaudatenbank’,
    ‘path’ => get_stylesheet_directory() . ‘/’ . ‘wpsl-templates/custom.php’,

    );

    return $templates;
    }

    add_filter( ‘wpsl_thumb_size’, ‘custom_thumb_size’ );

    function custom_thumb_size() {

    $size = array( 200, 300 );

    return $size;
    }

    add_filter( ‘wpsl_store_meta’, ‘custom_store_meta’, 10, 2 );

    function custom_store_meta( $store_meta, $store_id ) {

    $store_meta[‘excerpt’] = get_the_excerpt( $store_id );

    return $store_meta;
    }

    *******

    2.)

    In custom.php in /themes/zakra-child/wpsl-templates/ I have inserted the complete clone of store-listings-below.php (nothing changed in it so far):

    *** snip ***

    ?php
    global $wpsl_settings, $wpsl;

    $output = $this->get_custom_css();
    $autoload_class = ( !$wpsl_settings[‘autoload’] ) ? ‘class=”wpsl-not-loaded”‘ : ”;

    $output .= ‘<div id=”wpsl-wrap” class=”wpsl-store-below”>’ . “\r\n”;
    $output .= “\t” . ‘<div class=”wpsl-search wpsl-clearfix ‘ . $this->get_css_classes() . ‘”>’ . “\r\n”;
    $output .= “\t\t” . ‘<div id=”wpsl-search-wrap”>’ . “\r\n”;
    $output .= “\t\t\t” . ‘<form autocomplete=”off”>’ . “\r\n”;
    $output .= “\t\t\t” . ‘<div class=”wpsl-input”>’ . “\r\n”;
    $output .= “\t\t\t\t” . ‘<div><label for=”wpsl-search-input”>’ . esc_html( $wpsl->i18n->get_translation( ‘search_label’, __( ‘Your location’, ‘wpsl’ ) ) ) . ‘</label></div>’ . “\r\n”;
    $output .= “\t\t\t\t” . ‘<input id=”wpsl-search-input” type=”text” value=”‘ . apply_filters( ‘wpsl_search_input’, ” ) . ‘” name=”wpsl-search-input” placeholder=”” aria-required=”true” />’ . “\r\n”;
    $output .= “\t\t\t” . ‘</div>’ . “\r\n”;

    if ( $wpsl_settings[‘radius_dropdown’] || $wpsl_settings[‘results_dropdown’] ) {
    $output .= “\t\t\t” . ‘<div class=”wpsl-select-wrap”>’ . “\r\n”;

    if ( $wpsl_settings[‘radius_dropdown’] ) {
    $output .= “\t\t\t\t” . ‘<div id=”wpsl-radius”>’ . “\r\n”;
    $output .= “\t\t\t\t\t” . ‘<label for=”wpsl-radius-dropdown”>’ . esc_html( $wpsl->i18n->get_translation( ‘radius_label’, __( ‘Search radius’, ‘wpsl’ ) ) ) . ‘</label>’ . “\r\n”;
    $output .= “\t\t\t\t\t” . ‘<select id=”wpsl-radius-dropdown” class=”wpsl-dropdown” name=”wpsl-radius”>’ . “\r\n”;
    $output .= “\t\t\t\t\t\t” . $this->get_dropdown_list( ‘search_radius’ ) . “\r\n”;
    $output .= “\t\t\t\t\t” . ‘</select>’ . “\r\n”;
    $output .= “\t\t\t\t” . ‘</div>’ . “\r\n”;
    }

    if ( $wpsl_settings[‘results_dropdown’] ) {
    $output .= “\t\t\t\t” . ‘<div id=”wpsl-results”>’ . “\r\n”;
    $output .= “\t\t\t\t\t” . ‘<label for=”wpsl-results-dropdown”>’ . esc_html( $wpsl->i18n->get_translation( ‘results_label’, __( ‘Results’, ‘wpsl’ ) ) ) . ‘</label>’ . “\r\n”;
    $output .= “\t\t\t\t\t” . ‘<select id=”wpsl-results-dropdown” class=”wpsl-dropdown” name=”wpsl-results”>’ . “\r\n”;
    $output .= “\t\t\t\t\t\t” . $this->get_dropdown_list( ‘max_results’ ) . “\r\n”;
    $output .= “\t\t\t\t\t” . ‘</select>’ . “\r\n”;
    $output .= “\t\t\t\t” . ‘</div>’ . “\r\n”;
    }

    $output .= “\t\t\t” . ‘</div>’ . “\r\n”;
    }

    if ( $this->use_category_filter() ) {
    $output .= $this->create_category_filter();
    }

    $output .= “\t\t\t\t” . ‘<div class=”wpsl-search-btn-wrap”><input id=”wpsl-search-btn” type=”submit” value=”‘ . esc_attr( $wpsl->i18n->get_translation( ‘search_btn_label’, __( ‘Search’, ‘wpsl’ ) ) ) . ‘”></div>’ . “\r\n”;

    $output .= “\t\t” . ‘</form>’ . “\r\n”;
    $output .= “\t\t” . ‘</div>’ . “\r\n”;
    $output .= “\t” . ‘</div>’ . “\r\n”;

    if ( $wpsl_settings[‘reset_map’] ) {
    $output .= “\t” . ‘<div class=”wpsl-gmap-wrap”>’ . “\r\n”;
    $output .= “\t\t” . ‘<div id=”wpsl-gmap” class=”wpsl-gmap-canvas”></div>’ . “\r\n”;
    $output .= “\t” . ‘</div>’ . “\r\n”;
    } else {
    $output .= “\t” . ‘<div id=”wpsl-gmap” class=”wpsl-gmap-canvas”></div>’ . “\r\n”;
    }

    $output .= “\t” . ‘<div id=”wpsl-result-list”>’ . “\r\n”;
    $output .= “\t\t” . ‘<div id=”wpsl-stores” ‘. $autoload_class .’>’ . “\r\n”;
    $output .= “\t\t\t” . ‘

      ‘ . “\r\n”;
      $output .= “\t\t” . ‘</div>’ . “\r\n”;
      $output .= “\t\t” . ‘<div id=”wpsl-direction-details”>’ . “\r\n”;
      $output .= “\t\t\t” . ‘

        ‘ . “\r\n”;
        $output .= “\t\t” . ‘</div>’ . “\r\n”;
        $output .= “\t” . ‘</div>’ . “\r\n”;

        if ( $wpsl_settings[‘show_credits’] ) {
        $output .= “\t” . ‘<div class=”wpsl-provided-by”>’. sprintf( __( “Search provided by %sWP Store Locator%s”, “wpsl” ), ““, “” ) .'</div>’ . “\r\n”;
        }

        $output .= ‘</div>’ . “\r\n”;

        return $output;

        **** snap ****

        3.)
        Now I tried to find out where to

        “If you’re already using a custom search results template, then just include line 26 – 28 IN YOUR EXISTING TEMPLATE CODE to make the post content show up.”
        ( https://wpstorelocator.co/document/include-post-content-in-search-results/ )

        and then change ‘description’ into ‘excerpt’ in these lines like you described here:
        https://www.ads-software.com/support/topic/display-store-excerpt-instead-of-post-content/

        Where I fail is: Where exactly should I put the three line of code (26-28) into the template file?

        Your code example on the link above shows not the template, but the function.php code which is completely other than the template code. As I use a custom template, I only need theses three lines, you wrote, and put it into the TEMPLATE (or did I misunderstand this????).

        So to where in the template do I put it? There ist nothing similar to the (function.php) example given in the ‘store-listings-below.php’ template code…

        I want to use the custom template in order to reorder the store info output. Plus I might have to use some additional meta data etc. so I thought a custom template would be best to do all of this. But in the tempate given (store-listings-below.php) I can’t locate the output of all the single data fields, like phone, address and so far where I – as I think – will have to style an include fields as to my needs…? (Unfortunately my php skills are limited, but normally I recognise placeholders in templates and can reorder these.)

        That written, your how-to for custom meta data also shows the referring template parts as defined in function.php:
        https://wpstorelocator.co/document/add-custom-meta-data-to-store-locations/

        My aim is to show architectural locations. I’d like to list the category, would love to have tags, like to have something like architect and year of building, will not need opening hours… So a couple of customization ahead.

        Therefor I wanted the custom template to edit all this/insert the created fields there. Wrong?

        Best regards
        nici-

        Plugin Author Tijmen Smit

        (@tijmensmit)

        The template code you have is the one used to render the wpsl shortcode itself, the template code shown here is what renders the search results with this filter.

        In your case you need to use the last one.

        Thread Starter nici-

        (@nici-2)

        Thanks, Tijmen,

        that means, I basically do everything in the function.php?

        Best regards
        nici-

        Plugin Author Tijmen Smit

        (@tijmensmit)

        Yes, all custom code always has to go in the functions.php. This goes for every filter you use with any plugin.

        Thread Starter nici-

        (@nici-2)

        Thank you Tijmen,

        I got everything sorted and made it as I want it:
        https://holzbaupreis-eifel.de/HKZR/holzbaudatenbank/

        Only one thing is left: I need to change

        #wpsl-stores, #wpsl-direction-details, #wpsl-gmap {
        height: 350px !important;
        }

        into

        #wpsl-stores, #wpsl-direction-details, #wpsl-gmap {
        height: 100% !important;
        }

        percentage, not px.

        I tried to delete any input in the options in the referring field, but then there is 350px set in again (by default, I guess?) As this is put in inline, I can’t override it by styles.css.

        Any hint for this problem? It is the only thing that stands in the way for a perfect frontend output…

        Best regards an sooo much thanks for your help!
        nici-

        Plugin Author Tijmen Smit

        (@tijmensmit)

        You can often overwrite any inline CSS code by making it more specific, so include another div ID

        Try to add this to the appearance -> customize -> additional CSS page.

        #wpsl-wrap #wpsl-stores, #wpsl-wrap #wpsl-direction-details, #wpsl-wrap #wpsl-gmap {
        height: 100% !important;
        }
        • This reply was modified 4 years, 3 months ago by Tijmen Smit.
        Thread Starter nici-

        (@nici-2)

        Hi Tijmen,

        nope, unfortunately this didn’t fix it. I have a (very dirty) workaround now with adding ‘style=”height:100% !important”‘ inline to the custom template after $autoload_class.

        This overrides the — also set inline via the class — 350px. I am not sure, if the $autoload_class is needed here other than for the 350px? Could I just delete $autoload_class from my template here?

        However, for the moment I can live with this.

        I want to — again — say that I think your plugin is really amazing, also support and documentation ist great (when one is not temporarily blockheaded as I was initially ;-))! I was able to define custom meta fields, delete meta fields, I do not need from backend so my customer has a more straightforward backend form. I customized the search and excessively customized the store list…

        And again: I would go for Pro if you had one (I do not need any of the premium add ons). Or can I buy you a coffee? ??

        Best regards
        nici-

      Viewing 9 replies - 1 through 9 (of 9 total)
      • The topic ‘Excerpt in Store List / Custom Media’ is closed to new replies.