Search
 
SCRIPT & CODE EXAMPLE
 

PHP

custome route to a page with dynamic parameters wordpress

function custom_rewrite_rule(){
    $page_id = 318; // replace this ID with the page with the iFrame template 

    $page_data = get_post($page_id);

    if(!is_object($page_data)){
        return; // all other pages don't have to support custom deeplinks
    }

    // catches deeplinks 1 level deep, i.e.: /members/profile
    add_rewrite_rule(
        $page_data->post_name . '/([^/]+)/?$',
        'index.php?pagename=' . $page_data->post_name . '&memberspage=$matches[1]',
        'top'
    );

    // catches deeplinks 2 levels deep, i.e.: /members/profile/edit
    add_rewrite_rule(
        $page_data->post_name . '/([^/]+)/([^/]+)/?$',
        'index.php?pagename=' . $page_data->post_name . '&memberspage=$matches[1]&members_param=$matches[2]',
        'top'
    );

    // catches 3 levels deep, i.e. /members/profile/edit/confirm
    add_rewrite_rule(
        $page_data->post_name . '/([^/]+)/([^/]+)/([^/]+)/?$',
        'index.php?pagename=' . $page_data->post_name . '&memberspage=$matches[1]&members_param=$matches[2]&members_param2=$matches[3]',
        'top'
    );

}

add_action('init', custom_rewrite_rule);
Comment

PREVIOUS NEXT
Code Example
Php :: how to save snap in webcap in php codeigniter 
Php :: php month to local language 
Php :: laravel app not loading on server 
Php :: laravel permit only some inputs 
Php :: file viewer codeigniter 
Php :: multiple submit button form to multiple php files 
Php :: extract date from datetime object in php 
Php :: multiple slug in route 
Php :: laravel livewire refresh computed property 
Php :: make_dpcust 
Php :: echo (PHP 4, PHP 5, PHP 7, PHP 8) echo — Output one or more strings 
Php :: php sort multidimensional array by child value 
Php :: php script auf serve alle 5 minuten ausführen 
Php :: Laravel: validate an integer field that needs to be greater than another 
Php :: how to download file in laravel 8 delelete from directry 
Php :: php even odd 
Php :: run multiple php scripts parallel 
Php :: how to use “find_in_set” in cakephp 3 find method 
Php :: x-default wpml canonical alternate hreflang 
Php :: in packagemanifest.php line 131 undefined index name 
Php :: How to display limited post content in WordPress 
Php :: multi domain codeigniter 
Php :: laravel eloquent where date today 
Php :: use middleware in controller to have access session 
Php :: overwrite existing key value pair php 
Php :: wordpress wpdb delete 
Php :: laravel run controller from command line 
Php :: product slider shortcode woocommerce 
Php :: strings functions php 
Php :: order item add hook WooCommerce admin panel 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =