How to create new URL parameters friendly to Wordpress

0

Hello, I'm trying to create custom urls in Wordpress that are not present in my theme settings. I would like to know how I can do this kind of procedure.

I'm trying to create these two types of url

From https://meusite.com/listagem/?letra=a

For https://meusite.com/listagem/letra/a/

From https://meusite.com/listagem/page/2/?letra=a

For https://meusite.com/listagem/page/2/letra/a/

I copied and recreated the page creation function available in a file from my theme to create a custom page in the theme as seen in the code below.

// Listagem personalizada
    $dt_listagem_page = get_option('dt_listagem_page');
    if(empty($dt_listagem_page)){
        $post_id = wp_insert_post(array(
          'post_content'   => '',
          'post_name'      => __d('listagem'),
          'post_title'     => __d('Listagem personalizada'),
          'post_status'    => 'publish',
          'post_type'      => 'page',
          'ping_status'    => 'closed',
          'post_date'      => date('Y-m-d H:i:s'),
          'post_date_gmt'  => date('Y-m-d H:i:s'),
          'comment_status' => 'closed',
          'page_template'  => 'pages/listagem.php'
        ));
        $get_posts_page = get_option('siteurl').'/' . sanitize_title('listagem').'/';
        update_option('dt_listagem_page', $get_posts_page);
    }

The listing is working perfectly, plus the additional parameters mentioned above do not work in friendly url mode.

I have tried to rewrite the .htaccess file with a lot of Wordpress difficulty as can be seen below, because I am still a beginner.

# BEGIN WordPress
<IfModule mod_rewrite.c>
Options FollowSymLinks
AllowOverride All
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^listagem(/|)?$ index.php?page_id=21 [L]
RewriteRule ^listagem/letra/([a-z,0-9,A-Z,_-]+)/(/|)?$ index.php?page_id=21&letra=$1 [L]
RewriteRule ^listagem/letra/([a-z,0-9,A-Z,_-]+)/pagina/([0-9]+)(/|)?$ index.php?page_id=21&letra=$1&pager=$1 [L]
</IfModule>

# END WordPress

More when I write the friendly URL https://meusite.com/listagem/letra/a/ or https://meusite.com/listagem/letra/pagina/2/

Error 404 is displayed.

Note: I also activated the Custom Structure parameter with the /%category%/%postname%/ values in the <

I wonder if anyone can help me with this problem.

    
asked by anonymous 20.08.2018 / 05:07

0 answers