I have a structure like this for my custom post types: domain.com/member/member-name/book/book-name Basically, I have a custom post type of member, and the member-name is the post. What I want to do is pass a variable called books, but I can't get my code to work. I've based my solution on one that has previously been asked on here but my structure is different, and I've googled and googled to no avail. I really cant get my head around rewrite …
I am trying to Re-Write Page URL's so that they END with .htm I was able to do this using... /* Add .htm extension to Page URL Links */ add_action('init', 'htm_page_permalink', -1); function htm_page_permalink() { global $wp_rewrite; if ( !strpos($wp_rewrite->get_page_permastruct(), '.htm')){ $wp_rewrite->page_structure = $wp_rewrite->page_structure . '.htm'; } } /* Remove the trailing slash/ on Pages */ add_filter('user_trailingslashit', 'no_page_slash',66,2); function no_page_slash($string, $type){ global $wp_rewrite; if ($wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes==true && $type == 'page'){ return untrailingslashit($string); }else{ return $string; } } But then …
When trying to access the author's page (i.e. example.com/author/john) I am redirected to Woocommerce's shop page, however, if john is an admin, then I am redirected to author.php page correctly... any ideas why?
I'm trying to troubleshoot a wide-scale problem. I'd like to rewrite default WooCommerce permalinks for categories, to delimiter as commas. Let's take an example: Brand Model Generation Engine Product The permalink structure I'd like to have: /chip-tuning-Ford /chip-tuning-Ford-Focus /chip-tuning-Ford-MK3-FL /chip-tuning-Ford-MK3-FL-1.5TDCi-75kW /chip-tuning-Ford-MK3-FL-1.5TDCi-75kW-Basic-Box I did this via generate_rewrite_rules action, but currently, we have about 4000 categories and 9000 products, so each combination takes a lot of time and space. All rewrite rules by WP default are saved into one field on the …
The URL structure I am hoping for is as follows: All posts: /blog/ and /blog/page/2 Categories: /blog/%category%/ and /blog/%category%/page/2 Post: /blog/%category%/%postname%/ Tags: /blog/%tag%/ and /blog/%tag%/page/2 My problem is that I am unable to have both my permalink 'custom structure' and 'category/tag base' with the "blog" prefix, without having page or pagination 404 errors. I am working on a dev site which has no plugins and a custom theme which is not ineterferring. I would like a plugin-free solution which is …
I am experimenting with creating a simple plugin to create a custom post type named project but am having some trouble with the rewrite rules not been flushed on activation. I have the main plugin file with this function: register_activation_hook( __FILE__, 'Project_Custom_Post_Type::activate' ); Then within my class I have this: public function activate() { flush_rewrite_rules(); } My class has a construct of: public function __construct() { add_action( 'init', array( $this, 'register_post_type' ), 0 ); } I cannot see why it …
Hi I'm new to WordPress hence if my question was simple or stupid I'm sorry, but please someone tell me how to change URL for pagination pages. Currently I'm having URL for pagination pages as: www.example.com/category_name.html/1 www.example.com/category_name.html/2 www.example.com/category_name.html/3 etc. But I need to change this URL structure as: www.example.com/category_name.html?page=1 www.example.com/category_name.html?page=2 www.example.com/category_name.html?page=3 etc. I tried something like this but it's not working. add_action( 'init', 'add_author_rules' ); function add_author_rules() { add_rewrite_rule( "bycategory/108-abodes-of-vishnu)/?$", "category_name=$matches[1]&paged=$matches[2]", "top"); } Any help would be greatly appreciated.
Am trying to add custom path to my article posttype so my article path will be www.example/parent-post-1/parent-post-2/the-actual-post i tried to add this code /** * @param $post_link * @param $id * Добавить название категории продукта к ссылке * @return array|mixed|string|string[] */ function wpa_course_post_link($post_link, $id = 0) { $post = get_post($id); if ($post instanceof WP_Post) { $parent = get_field('parents', $post->ID) ?: []; $link = ''; foreach ($parent as $post) { $link .= $post->post_name . '/'; } if ($parent) { $post_link = …
I'm trying to re-write permalink structure with my own custom url in WordPress for a Divi Theme "project" I have already changed the "Divi slug" from "project" to "prodotti" so currently, the URL appears like this: http://www.example.com/prodotti/%postname%/ with my custom function function custom_post_name() { return array( 'feeds' => true, 'slug' => 'prodotti', 'with_front' => false, ); } add_filter('et_project_posttype_rewrite_args', 'custom_post_name'); I want to add to these urls a variable, that reside for each post in post_metadata, in order to build a …
I need to add a RewriteRule to my site. I have tried in .htaccess with no luck, it doesn't get parsed, so I'm all but giving up on that. I found the documentation on add_rewrite_rule, but have no idea where I'm supposed to use it. I am not writing a plugin. I need to put in one simple rule. I went to the functions.php file in what is the current theme folder. Is this the one I use? I inserted …
I have two custom post types colors shapes I have a post called "red" under the custom post type "colors". The default URL for this post would be example.com/colors/red Now I want to make it accessible from the following URL as well example.com/shapes/red The closest I came with is to add a filter to change_404_template (as I receive a 404 for above url) and forcefully inject the single.php file with some hacky code. Is there a way more standard method …
For a long time I served my blog from http://www.murrayc.com/blog/, with the wordpress installation in /home/murrayc/murrayc.com/blog/. Now I've moved it to http://www.murrayc.com/, without moving the wordpress installation on the filesystem. I did that by: Changing the "Site Address (URL)", in Settings->General, to http://www.murrayc.com. I kept the "WordPress Address (URL)" as http://www.murrayc.com/blog Adding a RedirectRule in my top-level .htaccess at /home/murrayc/murrayc.com/, so that, for instance, permalink/something could be used instead of blog/permalink/something. The older blog/permalinks still seem to work too. However, …
I have made my own routes by using add_rewrite_rule method. I would like to know if it is possible using given method to force all my created routes to redirect to URL where there is trailing slash in the end. For example if i do add_rewrite_rule('^my-route/', 'index.php?_my_route=1', 'top') or add_rewrite_rule('^my-route', 'index.php?_my_route=1', 'top') and i make a call to http://site.dev/my-route then it does not redirect it to http://site.dev/my-route/. If it is possible then i would be thankful for sharing :).
My current situation is: I'm redirecting the custom category request to below kind of url: http://my_url/news/category/abc I've managed to add my custom query var category and can get the query var now. The hook is as below: add_filter('rewrite_rules_array', function ($rules) { return ['^news/?$' => 'index.php?post_type=news&page=1&category=all'] + ['^news/category/(.+)/?$' => 'index.php?post_type=news&category=$matches[1]'] + $rules; }); Url like http://my_url/news/category/abc now goes to archive-news.php and list all posts which has custom category abc. And url like http://my_url/news/lalala goes to single-news.php and display full content of …
I have a Wordpress site that is built to be a job listing board, and I'm looking to create SEO friendly URLs based on data that is stored in the database. The URL structure should include the state abbreviation, city, and job title, and result in the following format: www.domain.com/job/ca/sacramento/janitor There is currently a "Job" page in the backend that uses custom page template located at 'page-templages/job-template.php' that displays the database information at the following URL: www.domain.com/job/?2020-412341235134 How can I …
I am stuck at redirecting one url to another url. I want to redirect https://samedomain.com/page-check-927GSJAYS639AL/highlights to https://samedomain.com/page-highlights/ (927GSJAYS639AL this is id it can be anything) the http://samedomain.com/page-highlights/ is the wordpress page The rewrite rule I tied in .htaccess file (added this in the first line it-self) is: RewriteEngine On RewriteRule ^page-check-([A-Z0-9_-]+)/highlights$ page-highlights?id=$1 [L] but I see a 404 error page It worked for RewriteEngine On RewriteRule ^page-check-([A-Z0-9_-]+)/highlights$ info.php?id=$1 [L] I also tried WP rewrite API php code UPDATE 1 add_action('init', …
folder structure docroot |- wordpress |- web.config |- wp-content |- japi |- index.php \- web.config ... ... As you can see there are 2 web.config s. One in the wordpress folder and one in wordpress/wp-content/japi folder. japi/web.config <rules> <rule name="Imported Rule 1" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" /> </rule> </rules> Now when I request for http://domain.com/wordpress/wp-content/japi/test. The japi/web.config seems to be neglected …
I have a page like http://example.com/mypage and I want to set some $_GET parameter like that: http://example.com/mypage/firstparameter/firstvalue I need firstparameter value but I always end in the 404 page. I've spent some hours with get_query_var(), add_query_vars_filter() and add_rewrite_rule() but no way... Thank you
We recently moved WP hosts. We backed up WP and imported it to a development site wp.mysite.com to get it all set up. Once everything was done, we switched the DNS and went live with newdomain.com on the new server. It's been running for a while but I now see a problem with plug-ins. The end user wanted to add a plugin but gets a 403 permissions denied error and at the top of the error it lists wp.mysite.com (the …
How can I generate dynamic pages on a Wordpress website from information provided in a separate MySQL database? I have a database with Locations and I would like to have a page for each of these created dynamically. For example, I have a database entry for LOCATION1. If the location exists in the database, I would like a page such as www.example.com/LOCATION1/ and for the content to be dynamic, using information from the database.