How to create a personalized archive message type that is different from the message type name

I created a post type called listingand a companion archive page archive-listing.php. When I go to /listings, the archive page loads properly. However, I would like the archive URL to be /marketplace. I define the property rewritebelow, but it does not seem to work. What am I missing?

register_post_type("listing",
    array(
        "menu_icon" => "dashicons-tag",
        "labels" => array(
            "name" => __( "Listings" ),
            "singular_name" => __("Listing")
        ),
        "public" => true,
        "has_archive" => true,
        "rewrite" => array("slug" => "marketplace"),
        "supports" => array("title", "editor"),
        "taxonomies" => array("listing_status")
    )
);
+4
source share
2 answers

When you register a new type of personalized message, you need to reset your permalinks.

"" → " " "" ( ).

-, , . flush_rewrite_rules(), after_switch_theme. : https://codex.wordpress.org/Function_Reference/flush_rewrite_rules

+2

- > Permalink , %% postname %%

+1

Source: https://habr.com/ru/post/1654078/


All Articles