• Resolved shoxt3r

    (@shoxt3r)


    Hi there,

    I’ve currently got a Custom Post Type of Cinemas which pulls through various Advanced Custom Fields data including a Google Map which shows all of the Cinemas on a map.

    Please could you tell me how I could use the Store Locator plugin alongside ACF to create a filterable Store Locator page? Each Cinema post has latitude and longitude values attached to them.

    Many thanks in advance!

Viewing 5 replies - 16 through 20 (of 20 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    There’s this code in the class-frontend.php that creates the default front-end template. But there’s nothing else in the code that forces a specific template.

    But it shouldn’t run if you created a single-your-cpt.php.

    I suspect therefore there is a conflict or something I’ve missed when changing the “stores” references to “theatres” – any thoughts please?

    You may have missed something, but it could also be the permalink / server cache that prevents it from working.

    Thread Starter shoxt3r

    (@shoxt3r)

    Ok so I’ve now gone back through a fresh version of the plugin and replaced anything related to “store” or “stores” with “cinema” or “cinemas”. However, while going through the “class-post-types.php” file I spotted it registers a post type using the following code:

                // The arguments for the cinema post type.
                $args = apply_filters( 'wpsl_post_type_args', array(
                        'labels'              => $labels, 
                        'public'              => $public,
                        'exclude_from_search' => $exclude_from_search,
                        'show_ui'             => true,
                        'menu_position'       => apply_filters( 'wpsl_post_type_menu_position', null ),
                        'capability_type'     => 'store',
                        'map_meta_cap'        => true,
                        'rewrite'             => $rewrite,
                        'query_var'           => 'cinema',
                        'supports'            => array( 'title', 'editor', 'author', 'excerpt', 'revisions', 'thumbnail' ),
                        'show_in_rest'        => $this->maybe_show_in_rest()
                    )
                );
    
                register_post_type( 'cinema', $args );

    Note that here, it’s registering my new post type of “cinema”.

    Now, I don’t know whether the rewrite is coming from the WP Store Locator Settings, or whether the following code I have in my “apex-post-types.php” file, but the “cinema” slug now redirects to “cinemas” which is what I want (I would guess my code in “apex-post-types.php” is redundant to be honest).

            function wp1482371_custom_post_type_args( $args, $post_type ) {
                if ( $post_type == "cinema" ) {
                    $args['rewrite'] = array(
                        'slug' => 'cinemas'
                    );
                }
            
                return $args;
            }
            add_filter( 'register_post_type_args', 'wp1482371_custom_post_type_args', 20, 2 );

    Now I’m in a situation whereby the “single” pages are working, but I still can’t get an archive or regular page to show, despite calling it “archive-cinema.php” and “page-cinema.php” to match the new post type registered via “class-post-types.php”.

    Any thoughts why the main page may not be loading? I just get a 404 when I try to visit /cinemas (which is rewritten from /cinema, remember :))

    Would it help to do a site export so you can see for yourself what the issue may be?
    I’ve done several Permalink saves and nothing seems to resolve it.

    • This reply was modified 3 years, 3 months ago by shoxt3r.
    • This reply was modified 3 years, 3 months ago by shoxt3r. Reason: Added detail about which version of plugin amended
    Plugin Author Tijmen Smit

    (@tijmensmit)

    Can you open a support ticket here, and attach the modified version of the plugin there so I can see what happens on my server.

    Thread Starter shoxt3r

    (@shoxt3r)

    Ok thanks Tijmen – I’ve sent a support ticket along with a WeTransfer link containing the zip file (I couldn’t attach it to the message itself as it wasn’t an accepted format).

    Many thanks for your help with this!

    Thread Starter shoxt3r

    (@shoxt3r)

    Ok, so just to feedback for anyone else coming across this thread – turns out I made the rookie error of not adding “has_archive” => true to the arguments list when the post type is registered within the “class-post-types.php” file. Oops!

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘ACF & Custom Post Type with Store Locator’ is closed to new replies.