I have a page www.website.com/merchant, this is a page post type. I placed a shortcode in this page to generate merchant information.

So If the URL is www.website.com/merchant/store1, that page will display the store1 information.

Now I want to remove the "merchant" slug from URL, so the URL would be www.website.com/store1

How to achieve this? Any help would be appreciated.

The code is below


    /*====== Start Rewrite URL function =========*/
    function merchant_page_query_vars($aVars) {
        $aVars[] = "website-name";
        return $aVars;

    add_filter('query_vars', 'merchant_page_query_vars');

    function landing_page_query_vars($aVars) {
        $aVars[] = "landing";
        return $aVars;

    add_filter('query_vars', 'landing_page_query_vars');

    function merchant_page_rewrite_rules($aRules) {
        $aNewRules = array('merchant/([^/]+)/?$' => 'index.php?pagename=merchant&website-name=$matches[1]');
        $aRules = $aNewRules + $aRules;
        return $aRules;

    add_filter('rewrite_rules_array', 'merchant_page_rewrite_rules');
    /*====== End Rewrite URL function =========*/

    function merchant_page() {

       //inside this function is the code to get information from database.


    function register_shortcode_merchant_page(){
       add_shortcode('merchant-page', 'merchant_page');

    add_action( 'init', 'register_shortcode_merchant_page');
  • What content type is store? What shortcode have you placed? Can you post the code? – cybmeta Dec 13 '14 at 11:35
  • This is a page post type. I edited the question, please check the code. – Wakanina Dec 13 '14 at 12:10
  • I think you are wrong or you didn't understand my question. I asked about what content type "store" is. You say that is a page post type but seeing your code I understand that "merchant" is a page, "store" is not a content type, it is a value for a custom query var. There is not a easy way to do what you want with actual content structure (a single page to all "store"). Instead, if you use a custom post type for your content if would be quite easy. – cybmeta Dec 13 '14 at 12:28

Your Answer

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

Browse other questions tagged or ask your own question.