Support » Plugin: WP Store Locator » Issue with wpsl_url – Can’t change it

  • Resolved one3rdnerd

    (@one3rdnerd)


    Hello,

    I have inherited a website that uses this plugin and has a modified single template for the store posts.

    I have looked at the template and it contains the below code

    $url = do_shortcode( '[wpsl_address url="true" phone="false" fax="false" name="false" email="false" address="false" address2="false" city="false" state="false" zip="false" country="false"]' );
    $url = wp_strip_all_tags($url);
    $url = str_replace('Url: ', '', $url);
    
    if($url != '') {
    	$button = '<div class="so-widget-sow-button" style="margin-bottom: 20px;">
    		<div class="ow-button-base ow-button-align-center">
    			<a href="'.$url.'" target="_blank" class="ow-button-hover" style="width: 100% !important;">Visit Dealer Website</a>
    		</div>
    	</div>';
    } else {
    	$button = null;
    }

    But for some reason I don’t see an URL field that can be edited but the existing posts do seem to have links. I looked one up in the database and that’s what led me to finding that they are stored in this meta key.

    Looking at https://wpstorelocator.co/document/create-custom-store-page-template/ suggests this field should exist somewhere.

    Am I missing something obvious?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi there,

    That piece of code doesn’t make much sense to me. Starting with the shortcode, [wpsl_address] is missing the mandatory id field, so that $url variable is never going to contain anything anyway, and the resulting $button variable is always going to be empty.

    If the shortcode had a valid store id, and assuming that particular store has a URL in its corresponding field, then it would retrieve the URL for that store in HTML format, and it would parse the output HTML into an ad-hoc $url variable to just get the url, so it can later be put inside of a button.

    The end result is something like this in the browser: https://ibb.co/XCnwp4d

    Let us know if we can help you with this starting from here.

    Thread Starter one3rdnerd

    (@one3rdnerd)

    @farroyob

    Thanks for your reply.

    Yes, it’s strange to me too. I didn’t create it.

    The stranger thing is it works, each store this button has a different link.

    The issue is, while most are correct there doesn’t seem to be a way to update them with a new one.

    Is there a way I can send you the complete php file so you can see the above code within more context as maybe that will make more sense?

    Here’s one of the pages where you can see this button (Visit Dealer Website)

    https://www.isuzutruck.co.uk/stores/aquila-truck-centres-tipton/

    The page is modified with ACF but since the URL on the button is stored in the database under wpsl_url I assumed this was a default meta field provided by your plugin but I can’t see it anywhere on the edit store screen.

    Hi,

    The telephone, fax, email and url fields are standard and you can edit them under the “Additional information” tab, see screenshot: https://ibb.co/YD8VpMX

    The snippet you sent makes sense in the context of the url you provided. Since it is the individual page for a store, the id is therefore not necesssary, I should have clarified that before.

    Please take a look at the additional fields when editing a store, because that is where you will find the url. No need for custom metadata or any other stuff.

    If you are still in trouble, get back to me and we’ll see how we can help you.

    Regards,

    Thread Starter one3rdnerd

    (@one3rdnerd)

    Ah, I don’t have that field

    https://ibb.co/2tgV8v1

    Do you know of any code that could have been used to unhook or hide it? If so I can try and search for it to see if the previous developer hacked it somehow.

    Thanks

    Hi again,

    Check your functions.php file in your theme to see if you have any customizations for the metadata for the different stores. If something is being hidden, you will probably find it there. If you are unable to figure this out, you can write us a ticket through support and we will help you from there.

    Regards,

    Thread Starter one3rdnerd

    (@one3rdnerd)

    Hi @farroyob

    I found the issue.

    The developer was adding custom fields and hadn’t included the URL option but they had been previously populated to existed in the database.

    I fixed this by changing

    
    function custom_meta_box_fields( $meta_fields ) {
    
        $meta_fields[__( 'Additional Information', 'wpsl' )] = array(
            'phone' => array(
                'label' => __( 'Aftersales Tel', 'wpsl' )
            ),
            'sales' => array(
                'label' => __( 'Sales Tel', 'wpsl' )
            ),
            'email' => array(
                'label' => __( 'Email', 'wpsl' )
            ),
            'url' => array(
                'label' => __( 'Url', 'wpsl' )
            ),
        );
    
        return $meta_fields;
    }
    
    add_filter( 'wpsl_frontend_meta_fields', 'custom_frontend_meta_fields' );

    To

    
    function custom_meta_box_fields( $meta_fields ) {
    
        $meta_fields[__( 'Additional Information', 'wpsl' )] = array(
            'phone' => array(
                'label' => __( 'Aftersales Tel', 'wpsl' )
            ),
            'sales' => array(
                'label' => __( 'Sales Tel', 'wpsl' )
            ),
            'email' => array(
                'label' => __( 'Email', 'wpsl' )
            ),
        );
    
        return $meta_fields;
    }
    
    add_filter( 'wpsl_frontend_meta_fields', 'custom_frontend_meta_fields' );

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.