How to implement very unusual wordpress routing structure?

Been trying the last two weeks to setup an unusual routing structure for a WordPress website but cannot manage to make it work. Basically there is a custom post type that will get the post url based on the post category(multiple categories) eg: site.com/movie-category/list/movie/ In this there are also news located at: Site.com/movie-category/news/ and for single news it will be site.com/moviecategory/thenews. Then another one called e.g. articles which are located at: Site.com/moviecategory/list/articles Site.com/moviecategory/list/articles/articlename A bunch of others too like /blog/post …
Category: Web

Redirect sub-page URLs to parent without changing URL

I am having an issue with redirect rules for a single-page app that is on a sub-page of a Wordpress site. I have followed this set of instructions pretty directly and am still having issues: Redirect sub-pages to parent without changing URL The subpages are custom post types for business locations. When someone visits http://business.com/hollywood-ca/contact it should pull up http://business.com/hollywood-ca/ but the url needs to remain the same (The contact portion of the URL is part of a single-page Vue.js …
Category: Web

Static raw HTML page

On the server there is a static HTML page example.html in my root folder of the WordPress install. Now when a user types www.example.com/example.html I want WordPress to be smart and bypass all normal routing behavior and instead just display that static example.html page. This looks so easy to me concept-wise but I can't find a solution after looking for hours. What exactly do I need to change in my .htaccess file? Is it even that .httaccess file or do …
Category: Web

Custom route and extract data from slashes and parameter

some external website is going to send a specific data into a WordPress site and need to extract and process it. The data is coming trough URL (between slashes and as parameter): domain.com/login_sso/username/timestamp/token?redirect=some-data I need to create some script that listens to that URL domain.com/logun_sso/ and extracts the username, timestamp, token and redirect parameter. Something like, when somebody hits domain.com/login_sso/ extract some data between slashes and paramter. I figured out to extract the parameters with parse_url but I don't know …
Category: Web

how do i create a specific handler for a url?

I want to create an image generator that will use a url like : /image-generator?a=1&b=2&c=3 The image generator will be dynamic and create an image based on the params. It will also output the image. So there will be no HTML and the header will return content-type: image/jpg. What's the best way to achieve this? I looked into creating a custom route, but apparently you're not supposed to do that. Do I need to create a custom type and a …
Category: Web

Can't access Wordpress via public IP

I recently installed apache and WordPress on top of that. I was capable of accessing the apache server via public IP but as soon as I installed WordPress I could no longer access the website. Does WordPress change the port because I enabled port forwarding for port 80 on my router. I also changed the WordPress Address and Site Address URLs but it caused the website to no longer function. Edit: It works after reinstalling WordPress by accessing it through …
Category: Web

How to display a raw HTML page (bypassing WordPress theme, scripts, etc)

I'm a software engineer with a WordPress site with hundreds of pages, and it's working very well. There are certain cases, however, where I'd love to be able to code my own page with no interaction with / interference from the WordPress system (no themes, no styles, no javascript, etc) yet still have it located on that same subdomain. How can I set https://example.com/special-page to display an HTML file uploaded somewhere within /wp-content/? And as a bonus, I'd love if …
Category: Web

WP returns to domain root instead of siteurl

On various admin actions (e.g. delete a post), my fresh WP install (dev.mydomain.com/website) returns to the domain root (dev.mydomain.com) instead of dev.mydomain.com/website/wp-admin/edit.php?some-vars-here. I've setup the WP_HOME and WP_SITEURL to the correct site url, but no difference. Site runs over ssl on Apache (I've added the $_SERVER['HTTPS'] = 'on' to wp-config.php). I am able to browse the complete wp-admin and the post is deleted on a delete action, but just jumps to the wrong url after completion. I feel like I'm …
Category: Web

WordPress and VueJS routing problem

I am testing the integration of a VueJS app in WordPress. It actually works (no styles yet). BUT If I access a URL like https://example.com/my-vue-route/about, the .htaccess URL rewriting redirects any incoming HTTPS request to the index.php of WordPress. So I actually never land on /my-vue-route/about but on the /about page, as WordPress thinks I made a typo. Is it somehow possible to keep the vue routes out of this URL rewriting?
Category: Web

Custom URL rewrite rules for a web app

I'm working on a wordpress install that functions more like a web application than a traditional website, and I'm trying to get my head around the add_rewrite_rule system. Currently I have three custom post types called "Programmes", "Surveys", and "Candidates". Each programme has multiple surveys, and each survey has multiple candidates. I currently have a URL structure like the following: Programme Overview: /programmes/programme-1/ Survey Overview: /programmes/programme-1/?survey=survey-1&view=overview Survey Candidates: /programmes/programme-1/?survey=survey-1&view=candidates&page=1 Candidate Overview: /programmes/programme-1/?survey=survey-1&view=candidate-1 This works okay but is obviously a bit …
Category: Web

How do you load a different page in WordPress

I need to have a page display a different page depending on the content of a cookie. I can do this using a 301 redirect, but it's slow. I want to do it entirely within WordPress using a plugin if this is possible. I do not want to cause a trip back to the browser. Keeping the original url is actually a positive effect in this case.
Category: Web

WordPress with Tor Onion Service (dual .com & .onion domains for same website)

I'd like to make my existing wordpress website www.example.com also accessible over a tor onion service = www.examplesite12345.onion. How can I do this? Note that the two domain's content should be identical, except that I don't want wordpress to be injecting the wrong domain into my content (of course, all my content won't specify the domain either). I'm using wordpress multisite. I setup tor to point to my web server, but wordpress doesn't recognize the domain (not surprising). So wordpress …
Category: Web

How to route root path / to /xyz in nginx?

I am using PHP based application in which i need to configure Nginx. I wanted to forward only path / to /?product_cat=top and all other request will remains same. below is my Nginx configuration: server { server_name default_server; listen 80; root /var/www/wordpress; underscores_in_headers on; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, PATCH'; add_header Allow "GET, POST, HEAD, OPTIONS, PATCH" always; access_log /var/log/nginx/ecom.log json; error_log /var/log/nginx/ecom-error.log; index index.php index.html index.htm ; location = / { return 301 /?product_cat=top; } location ~ \.php$ …
Category: Web

Extend page routing with custom parameters

In WordPress there is defined a simple routing /%postname%/ So when I access /projects/ it loads me Projects page which has specified custom template_projects.php template. Is it possible to extend routing but only for this template ? Let's say I want to extend routing to handle project id, so it should be: /%postname%/%project-id%/ But other pages will work with base route.
Category: Web

Child page in custom post throws 404 page not found

Currently I am trying to add a page as a child in my custom post section. The parent pages in my custom posts works correctly, I've set a template file for them as singe-custom_post_name.php. All good. Now I have added support to create child pages, I am able to create those pages in my custom post type section but when I navigate to the url a template couldn't be found. What are the possible problems or solutions to this kind …
Category: Web

How to change all routes with language codes

I need to dublicate all existing routes with several language codes: /2020/03/11/Hello-world /en/2020/03/11/Hello-world /de/2020/03/11/Hello-world /Hello-world-page /en/Hello-world-page /de/Hello-world-page /... /en/... /de/... Then I need to pre-handle all routes to check prefix exists and get as slug, then let related handlers do thier jobs.. I searched it many many times but never lucky to solve.. How to accomplish that? Thank you!
Category: Web

Custom routes for custom post type?

I have a custom post type called 'event'. An event has multiple subpages like registration, speakers, contact us, etc. Currently the content is saved as one or more custom fields. I would like to have an url structure like events/{event_slug}/registration events/{event_slug}/speakers events/{event_slug}/contactus With each URL displaying the information from each custom field, respectively. Is there a way, we can achieve this in WordPress?
Category: Web

.htaccess for wordpress in separate folder

I'm working on a really odd site which has a couple of Magento installs next to a Wordpress install. the folder structure looks like this: /shop (magento) /shop-world (magento) /wp .htaccess I just installed Yoast on the Wordpress install and the first thing it did was edit the Wordpress .htaccess settings without creating a backup. How can I edit this: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule …
Category: Web

wp_get_nav_menu_items doesn't return custom post type item

I try to achieve a menu like this (this is the actual menu). There is a tree of projet coordinated by the wordpress menu that manage route and navigation. Here is a scheme of the menu and the corresponding route. PROJECT | |__ PAINT (SITE_URL/paint) | |__ post_1 (SITE_URL/paint/post_1) | |__ VIDEO (SITE_URL/video) |__ post_2 (SITE_URL/video/post_2) |__ post_3 (SITE_URL/video/post_2) First of all, know that post_1, post_2 and post_3 are custom post type generated here by CPT UI. I need to …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.