add_rewrite_rule
to manage some data structures that exist outside of WordPress but are stored in the same Database. Here is my rewrite rule for reference:
add_rewrite_rule('^tf/?([^/]*)/?','index.php?tf=true&user-date=$matches[1]','top');
This all works fine with the Pilotpress plugin disabled but as soon as I turn that plugin on it limits the visibility of this page and redirects the logged in users I want to the home page.
Is there a simple way to make this rule work? Failing that we will have to set up a page with the correct template and then use get parameters in the URL string. I’m hoping somebody else has had the same issue or theres a little-known fix from an admin.
Thanks
]]>I recently had problems with pagination in the query, and I discovered that the problem was in the wordpress rewrite rule that did not direct correctly due to an excerpt:
“genero/([^/]+)/page/?([0-9]{1,})/?$”,
which should correspond to:
“index.php?genre=$matches[1]&paged=$matches[2]”
(I was able to access normally),
after some time I managed to make it work by removing the expression and adding another rule without the excerpt : “{1,}”, what I would like to know is if this snippet is some kind of bug because all the custom types with this snippet are having problems, or if it is an error in my code
follow my solution:
add_rewrite_rule( 'genero/([^/]+)/page/?([0-9])/?$', 'index.php?genre=$matches[1]&page=$matches[2]', 'top' );
notice, I took the opportunity to replace the query var “paged” with “page”, but I tried to search for “paged” before adding this rule
again sorry if it’s a big mess of mine, i’m new to it and if you need more information just let me know i’ll try to answer as soon as possible
I had also tried to flush the rules and change to /% postname% / in the permalinks
]]>Here you see my code, which do this:
add_rewrite_rule(
‘test/([^/]*)’,
‘index.php?pagename=test&testcontent=$matches[1]’,
‘top’
);
add_rewrite_tag(‘%testcontent%’, ‘([^&]+)’);
Does AMP supports this?
I want to send all my sites exmaple.com/test/contentA … exmaple.com/test/contentX (more than 4000) to Google.
Thanks a lot!!
BR
Matthias
function custom_rewrite_basic() {
add_rewrite_tag('%blog_category%','([^&]+)');
add_rewrite_rule('^blog/category/([0-9a-zA-Z+-]+)/?', 'index.php?pagename=blog&blog_category=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic', 1);
It works when the plugin is disabled. For example, I can go on URL: “www.site.com/blog/category/my-cat” and it will work.
But when the plugin is enabled, during a visit to this link, redirecting to “www.site.com/blog” occurs (screenshot)
P.S.
Blog – this is the real page that exists on the site.
Please tell me what could be the problem..
]]>I wanted to create a customized url for my (test-)site -> https://blubb.enif.uberspace.de/wordpress/project/?id=1
I want to turn the “id=1” part into something else (based on the id) like “/project/cookies”.
I used following codex/support sites but even the examples there doesn’t seem to work on my website:
– https://codex.www.ads-software.com/Rewrite_API/add_rewrite_rule
– https://codex.www.ads-software.com/Class_Reference/WP_Rewrite
– https://codex.www.ads-software.com/Custom_Queries#Permalinks_for_Custom_Archives
I am creating a url by add_query_arg() by adding some query string to the url in a ajax call. So the new url will be like this https://example.com/seminar/?id=12 , where seminar is a page having page slug seminar.
I’m sending this url in ajax respone and redirecting to it.
So, I want that the url should automatically turn into like this:
https://example.com/seminar/12
and I also want to use id parameter.
Currently I’m coding like this:
add_action(‘init’, ‘custom_rewrite_rule’);
add_filter(‘query_vars’, ‘wpse12965_query_vars’ );
add_action( ‘init’,’my_flush_rules’,50 );
// flush_rules() if our rules are not yet included
function my_flush_rules(){
$rules = get_option( ‘rewrite_rules’ );
if ( ! isset( $rules[‘seminar/([^/]+)/?$’] ) ) {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
}
function wpse12965_query_vars( $query_vars )
{
$query_vars[] = ‘id’;
return $query_vars;
}
function custom_rewrite_rule() {
add_rewrite_rule(‘seminar/([^/]+)/?$’,’index.php?pagename=$matches[1]&id=$matches[2]’,’top’);
}
But it seems like not working. Niether the url is changing nor the id parameter is adding to query_vars[] in $wp_query variable.
Anyone, Please suggest.
Thanks,
Darik
I enabled the categories for pages. so i can link my pages to a category.
but when i visit the page the url is example.com/pagename
could anybody help me figure out how i can get the category name in between the page and the domain name?
example.com/categoryname/pagename
i tried something like this:
add_rewrite_rule();
but regular expressions i barely understand.
Thanks a lot for your help!
]]>https://www.ads-software.com/plugins/nextgen-gallery/
]]>FROM:
https://example.com/test/portfolio/?pslug=plants
TO:
https://example.com/test/portfolio/plants
Details below:
With WordPress Permalink Settings set to “Post name”, my current portfolio URL is: https://example.com/test/portfolio/
My links on this page points to: https://example.com/test/portfolio/?pslug=plants
pslug is the custom parameter I added.
my functions.php
function add_query_vars($vars){
$vars[] = "pslug";
return $vars;
}
add_filter('query_vars', 'add_query_vars');
function add_portfolio_rules() {
add_rewrite_rule('portfolio/([^/]+)/?$', 'index.php?page_id=117&pslug=$matches[1]', 'top');
}
add_action('init', 'add_portfolio_rules');
Please help!!! I have tried everything but nothing works.
Thanks!!!
<?php
function add_query_vars($new_var) {
$new_var[] = "ps";
$new_var[] = "page";
return $new_var;
}
add_filter('query_vars', 'add_query_vars');
function add_rewrite_rules($myrules) {
$newrules = array(
'^acer/(aspire_e|aspire_p|aspire_m)/?$' => 'index.php?page_id=997&ps=$matches[1]', 'top', '^acer/(aspire_e|aspire_p|aspire_m)(/page/?([0-9]{1,}))/?$' => 'index.php?page_id=997&ps=$matches[1]&page=$matches[2]', 'top'
);
$myrules = $newrules + $myrules;
return $myrules;
}
add_filter('rewrite_rules_array', 'add_rewrite_rules');
?>
but when I apply add_rewrite_rule pagination doesn’t work anymore. Though the add_rewrite_rule gives the URL
www.mysite.com/acer/aspire_e/page/2/ for example.
Have anyone here encountered this error? any help would be appreciated.
https://www.ads-software.com/plugins/wp-pagenavi/
]]>