0

I created a custom taxonomy with the following code in functions.php (child theme) :

    add_action( 'init', 'create_location_taxonomy' );

    function create_location_taxonomy() {
        $labels = array(
            'name'                           => 'Locations',
            'singular_name'                  => 'Locations',
            'search_items'                   => 'Search Location',
            'all_items'                      => 'All Locations',
            'edit_item'                      => 'Edit Location',
            'update_item'                    => 'Update Location',
            'add_new_item'                   => 'Add New Location',
            'new_item_name'                  => 'New Location Name',
            'menu_name'                      => 'Location',
            'view_item'                      => 'View Location',
            'popular_items'                  => 'Popular Locations',
            'separate_items_with_commas'     => 'Separate locations with commas',
            'add_or_remove_items'            => 'Add or remove location',
            'choose_from_most_used'          => 'Choose from the most used location',
            'not_found'                      => 'No location found'
        );

        register_taxonomy(
            'Location',
            'post',
            array(
                'label' => __( 'Location' ),
                'hierarchical' => false,
                'labels' => $labels,
                'public' => true,
                'show_in_nav_menus' => false,
                'show_tagcloud' => false,
                'show_admin_column' => true,
                'rewrite' => array(
                    'slug' => 'locations'
                )
            )
        );
    }

This allows me to add a location to each of my posts and in the admin page, under post, I see "Location" under "Tags" where I can manage them.

I already know how to make a list of my custom taxonomy and when I click on a custom taxonomy link (e.g. http://example.com/locations/abc), I get to a page that displays all posts with the according custom taxonomy.

Now I am trying to do the following : I want to design this page (the ones that displays all posts) under my wordpress admin according to a specific template, so that the posts of a specific custom taxonomy are displayed the way defined by the template of the page in my admin.

I have no idea if that is possible and if so, how to do it...but I need the page to be done via the wordpress admin (and not only by creating a taxonomy-location.php page with my code in it, since the template of the page is generated via the admin wordpress in fact).

Thanks for any help!

EDIT : tl;dr is it possible to create a new page (e.g. Locations with slug being 'locations'), from admin panel, that will be used for custom taxonomy. Hence when accessing the page http://example.com/locations/abc, I get all posts with custom taxonomy abc ?

0

While WP will helpfully construct many of admin pages for you, you can just as easily create your own from scratch.

add_menu_page() allows you to register arbitrary admin page and have full control over it.

  • I corrected my initial post to add a bit of clarification. I am not trying to add a page in my admin in the way you are saying, I am trying to use a page designed under the "Pages" in the menu, that will be the template used to display the posts of a specific custom taxonomy – hycday Jun 6 '17 at 8:17
  • I am not following the distinction you are making. You can the page in admin anywhere and how it works is up to you. – Rarst Jun 6 '17 at 8:39
  • I am not trying to add a menu page, or admin page. I am trying to use a page designed in the admin via Visual Composer, to display the posts of a custom taxonomy in a certain way. Currently, these posts are displayed like a regular blog (i.e. one after the other), whereas if I design it via the Visual Composer I can have my posts displayed as a grid. I want to do it via the admin because the code will be generated via Visual Composer. – hycday Jun 6 '17 at 8:43
  • ...designed in the admin via Visual Composer... aaaand you are on your own from this point, no remote idea how that works, sorry. :) – Rarst Jun 6 '17 at 8:48
  • The Visual Composer detail is not really important. The question itself is : how to display posts that belong to the custom taxonomy, on a page (archive type I would say) that is created from the admin ? – hycday Jun 6 '17 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.