• Resolved meijersjc

    (@meijersjc)


    Absolutely loving Stellar Places, refreshing after testing so many plugins. I’m just doing my head in with one issue: changing the slug, without tampering with the plugin code itself.

    I’ve been trying to use a child theme’s functions.php, with my limited skills, unfortunately whichever approach I try the result always is a “page not found” error.

    function custom_map_rewrite($args) {
    	$args['rewrite']['slug'] = 'locatie';
    	return $args;
    }
    
    add_filter( 'stlr_place-post_type_args', 'custom_map_rewrite' );

    I’d appreciate a hand ??

    https://www.ads-software.com/plugins/stellar-places/

Viewing 10 replies - 1 through 10 (of 10 total)
  • @meijersjc

    Your code looks correct. Just be aware that after adding that code, you will need to visit the ‘Permalinks’ page in the WordPress admin area. Doing this will flush the rewrite rules and make your locations show under the new slug.

    Alternatively, disabling and then re-enabling the plugin will do the same thing.

    Glad to hear it’s been a pleasant experience!

    Thread Starter meijersjc

    (@meijersjc)

    Cheers for the quick answer! I’m not out of the woods yet though, if those steps should solve the matter I must have a conflict somewhere else – as it’s not picking it up. Puzzling, but I’ll update once I figure it out, might also have something to do with this test site being a local one.

    But yes, very very refreshing. I can think of feature requests, but there’s this little voice in the back of my mind arguing against it ?? It’s lightweight, easy to manage.

    Thread Starter meijersjc

    (@meijersjc)

    Figured it out, caching issue following minification – so entirely unrelated to the plugin itself ??

    Marking as resolved!

    Glad to hear! Feel free to suggest feature requests. I’m already considering a number of extensions to the plugin, but plan to keep the core plugin lean and clean. ??

    Thread Starter meijersjc

    (@meijersjc)

    Hehe. Well, one thing I can think of would be to match the addres format to WP install settings. For example, 123 Abbey Road is fine in the UK, but in this country it causes eyebrows to go up (like most “European” countries it’s the other way around here :P)

    Depending on site locality that may be an issue. Google seems smart enough, but local search or directory sites tend to stumble over malformatted (their words) addresses when processing either itemprop or straight json-ld.

    I’m trying to figure out how to rewrite the output on page, there’s got to be a way, but I”m not so sure whether for the schema it’s feasible without making alterations to the plugin code itself.

    Thread Starter meijersjc

    (@meijersjc)

    Popping back in, I noticed that the slug ID isn’t rewritting in breadcrumbs, it’s displayed as “Place”.

    Now it might be me, trying to rewrite the above function to take this into acount, but I just can’t seem to find where that specific “Place” comes from?

    (also, any chance you’d consider extending the shortcode options to also display a text list of the address details? ?? Maybe best as a second shortcut, so that it could be placed elsewhere?)

    @meijersjc,

    I’m not sure what you are using for breadcrumbs, but I believe the ‘Place’ text in your breadcrumbs is likely coming directly from the post type labels. You may need to use the same filter you used to update the slug to relabel things.

    I’ve created a ticket for your feature request here: https://github.com/wpscholar/stellar-places/issues/16

    Feel free to comment on the issue with any pertinent details.

    I also created an issue regarding the address formatting: https://github.com/wpscholar/stellar-places/issues/17

    Thread Starter meijersjc

    (@meijersjc)

    Wonderful ??

    As for breadcrumbs, this is with Yoast’s breadcrumb feature active, as well as inactive (native WP). So yeah, time to figure out a rewrite function which also handles the post type labels.

    I left a comment in the Github issue – somehow I managed to completely miss Stellar Places there, apologies.

    I am looking at doing something similar and I want to change Places to Dive Sites. Here’s my code that works.

    function custom_map_rewrite($args) {
        $labels = array(
            'name'                  => __( 'Dive Sites', 'dive-center' ),
            'singular_name'         => __( 'Dive Site', 'dive-center' ),
            'menu_name'             => _x( 'Dive Sites', 'Admin menu name', 'dive-center' ),
            'add_new'               => __( 'Add Dive Site', 'dive-center' ),
            'add_new_item'          => __( 'Add New Dive Site', 'dive-center' ),
            'edit'                  => __( 'Edit', 'dive-center' ),
            'edit_item'             => __( 'Edit Dive Site', 'dive-center' ),
            'new_item'              => __( 'New Dive Site', 'dive-center' ),
            'view'                  => __( 'View Dive Site', 'dive-center' ),
            'view_item'             => __( 'View Dive Site', 'dive-center' ),
            'search_items'          => __( 'Search Dive Sites', 'dive-center' ),
            'not_found'             => __( 'No Dive Sites found', 'dive-center' ),
            'not_found_in_trash'    => __( 'No Dive Sites found in trash', 'dive-center' ),
            'parent'                => __( 'Parent Dive Site', 'dive-center' ),
            'featured_image'        => __( 'Dive Site Image', 'dive-center' ),
            'set_featured_image'    => __( 'Set dive site image', 'dive-center' ),
            'remove_featured_image' => __( 'Remove dive site image', 'dive-center' ),
            'use_featured_image'    => __( 'Use as dive site image', 'dive-center' ),
            'insert_into_item'      => __( 'Insert into dive site', 'dive-center' ),
            'uploaded_to_this_item' => __( 'Uploaded to this dive site', 'dive-center' ),
            'filter_items_list'     => __( 'Filter dive sites', 'dive-center' ),
            'items_list_navigation' => __( 'Dive Sites navigation', 'dive-center' ),
            'items_list'            => __( 'Dive Sites list', 'dive-center' ),
            'featured_image'        => __( 'Dive Site Image', 'dive-center' ),
            'set_featured_image'    => __( 'Set dive site image', 'dive-center' ),
            'remove_featured_image' => __( 'Remove dive site image', 'dive-center' ),
            'use_featured_image'    => __( 'Use as dive site image', 'dive-center' ),
            'insert_into_item'      => __( 'Insert into dive site', 'dive-center' ),
            'uploaded_to_this_item' => __( 'Uploaded to this dive site', 'dive-center' ),
            'filter_items_list'     => __( 'Filter dive sites', 'dive-center' ),
            'items_list_navigation' => __( 'Dive Sites navigation', 'dive-center' ),
            'items_list'            => __( 'Dive Sites list', 'dive-center' )
        );
        $args['labels'] = $labels;
    	$args['rewrite']['slug'] = 'divesites';
    	$args['description'] = __( 'This is where you can add new dive sites to your site.', 'dive-center' );
    	return $args;
    }
    add_filter( 'stlr_place-post_type_args', 'custom_map_rewrite' );
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Changing the slug’ is closed to new replies.