Questions tagged [template-redirect]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 views

Polylang: How to make detect browser language works on all pages? [closed]

I need to make links on the site redirect to the language version "Detect browser language" option in Polylang settings allows me redirect only homepage, but i need to do this for all pages ...
Danil Tivikov's user avatar
0 votes
2 answers
34 views

How to redirect my homepage

My wordpress theme uses templates but I want to temporarily redirect the homepage which uses the template "page.php" to a category page which uses a template file. Can I use a redirect ...
Amena's user avatar
  • 1
0 votes
1 answer
240 views

How to stop wordpress from redirecting from the post's old slug after changing title and slug?

After changing a post's title/slug from mysite.com/name to mysite.com/new-name, the old slug mysite.com/name is now redirecting to the new one mysite.com/new-name, and I don't want that to happen. I ...
cashrunner's user avatar
0 votes
0 answers
25 views

Changing the redirection of a restricted url

I've almost finished setting up a website as a complete laymen and i used a function posted on here that allows hyperlinks to be only visible to logged in users. The function works completly fine, all ...
Benjamin's user avatar
0 votes
1 answer
115 views

Redirect wp-sitemap.xml not working

I'd like to redirect wp-sitemap.xml to a custom sitemap file. I'm using template_redirect but the request isn't redirected. I attempted to debug it with die() but it doesn't work either. function ...
Ryan's user avatar
  • 53
0 votes
1 answer
44 views

Load a specific post if user tries to access 404 page

First, I'm not trying to redirect the user as I don't want the URL to change - think of it as an include rather than a redirect. Second, I would want to have control over the content, title, etc. So ...
Roz's user avatar
  • 21
0 votes
0 answers
60 views

Cannot find redirect - Wordpress behind HTTPS proxy (Cloudfront)

I have a Wordpress installation sitting behind Cloudfront. SSL termination is done on Cloudfront, with the web server listening on Port 80 only. The following additions have been made to wp-config.php ...
jdog's user avatar
  • 101
0 votes
1 answer
67 views

Template Redirect Function Only Working When Logged In

I added a template_redirect to my functions.php file, which redirects private staff members to a "Staff No Longer Available" page. However, my code only works when I am logged in. Am I ...
Michelle's user avatar
1 vote
2 answers
281 views

Creating FPDF directly in the browser using template_rediect

I am trying to create a pdf using fpdf, which opens in a browser window. Ultimately, the data will be passed from a form submit to a non-existent WP page called pdf. I am checking for this in ...
StripyTiger's user avatar
0 votes
1 answer
136 views

send popup after wp_redirect()

Hello Wordpress Developer, I want to ask about how to send popup after wp_redirect(); I'm sending link to user for verify. I just want to let user know that the verify process is done. Here is the ...
Hendra's user avatar
  • 5
1 vote
0 answers
51 views

Serve specific "template" page at any URL that ends in its slug

Still new to WordPress, so please go easy on me. Goal: Prevent users of a specific role from viewing other custom post types made by users of same role. Intended solution: Modify the URL and redirect ...
Ryan Cochran's user avatar
0 votes
1 answer
46 views

Redirect page without changing the url

I have a page running a custom shortcode. When an element on the page is clicked I am pushing a new url into the browser (using history.pushstate) and displaying the content in the same window. If ...
StripyTiger's user avatar
1 vote
0 answers
40 views

Adding rewrite rule dynamically for search results redirecting to 404 URL

We need the search url structure like the below URL : https://siteurl.com/in/chennai/accountant/ We have already a post url with same structure for single post detail page URL : https://siteurl.com/in/...
RagEsh's user avatar
  • 11
1 vote
1 answer
75 views

How to correctly detect accessing wp-content/uploads?

Not sure if this is a stupid question or not; however, I've been trying to detect when a user accesses a PDF. I want to be able to know how often a user is accessing specific PDF files. I have been ...
please_help_me's user avatar
0 votes
0 answers
52 views

Template_redirect works, but headers aren't sent when checking via cURL

I'm creating a 307 redirect to maintenance page for when my site goes through maintenance. My PHP class is included in functions.php, and gets instantiated immediately. In my __construct, I call: ...
user1702965's user avatar
0 votes
0 answers
121 views

auth_redirect() doesn't send users to the page where they orginally tried to acces

In the site I am building, I'm using "theme my plugin" so I could make my own login, logout, registration pages. For the login form, I used the default wp_login_form input names, and the ...
T3mmX's user avatar
  • 13
0 votes
1 answer
197 views

Custom Login page, redirection and restrictions

I'm having some issues with my custom login page with redirections and restrictions. Any user can browse a 'community' page but they can't access the 'distributors' pages. I have set a rule so if ...
Maluco's user avatar
  • 1
1 vote
2 answers
151 views

Redirect Users who aren't logged in, aren't post authors and aren't admin. Frontend

Very new to PHP and I'm trying to do the following through a snippets plugin but keep getting critical errors: Restrict all non-logged in users to home, about and pricing pages. If attempting to ...
Jake Billington's user avatar
0 votes
2 answers
765 views

How to redirect to category page if page does not exists?

In my current case, the system try to find a page and show 404 if it does not find. I would like with the same url... like https://example.com/{{slug}}/ Check if a page with this slug exists : Yes - ...
J.BizMai's user avatar
  • 820
0 votes
1 answer
132 views

Page get parameter doesn't work with is_single() function

If exist the page parameter in the blog post, I have to redirect to the 404 page instead of current post URL. I tried to check the current page type (is singular) and try to get page parameter in the ...
MT09's user avatar
  • 13
0 votes
1 answer
84 views

Intercept loading of a certain page

Depending on whether user registration is enabled on my site or not, I want to prevent loading of my custom login form and display a popup instead telling the user that registration is disabled. I ...
Razzupaltuff's user avatar
0 votes
1 answer
56 views

Why does the $_GET parameter ?search forward the front-page to the archive/blog page

I need the $_GET parameter ?search for my front-page for a third party plugin. Whenever I enter http://wp-site.tld/?search=foo I get redirected to the blog/archive page. If I enter http://wp-site.tld/...
BonisTech's user avatar
  • 262
0 votes
1 answer
242 views

Detect if requested page is PWA on server side

I'm trying to determine if the user is browsing PWA on server side. On client side I can check if the browser mode is standalone via JavaScript and detect PWA, but on server side this is not an option....
DaftPlug's user avatar
1 vote
1 answer
238 views

Redirect all child taxonomy to its parent

Is it possible to automatically redirect a child taxonomy to its parent, therefore not having a public page at all for the child taxonomy? Example: I have a taxonomy called venue, this is set up with '...
robwatson_dev's user avatar
1 vote
1 answer
387 views

Redirect specific page in Wordpress for first time visit

I tried the following to redirect one page on the first visit: function check_for_redirect() { if( is_page( 8219 ) ) $days_to_expire = 30; if (!is_admin() && !isset($_COOKIE['...
Rens's user avatar
  • 11
0 votes
0 answers
34 views

I want to replace after WordPress is completely loaded

The replacement process is always done with the following code. You can also use filter hooks, but some themes are hard-coded and you can't use filters. So I'm using this code (template_redirect ...
nodoka's user avatar
  • 1
0 votes
0 answers
16 views

How to add a switch to admin area which enables/disables crisis-mode: Redirect all traffic to certain page if switch is enabled

Case: There is natural disaster or terrorist attack etc. Admin logins to site and enables "crisis mode". All traffic gets redirected to crisis page. I found this code from another answer ...
Antti Mäkelä's user avatar
0 votes
1 answer
96 views

Redirect logged in users from a custom post type archive page if they don't have a specific role

I have a Custom Post Type named flashcard and post of that type are listed by an archive-flashcard.php template. The bellow function force flashcard posts to be listed only for posts authors (they ...
Yurié's user avatar
  • 1,101
0 votes
2 answers
1k views

URL Rewriting for PHP script on an image URL

I built an image randomizer so that when I open a .php file in a URL that it displays the image with readfile($randomImage);. This works locally but when I upload it to the server it gets blocked by ...
w.jelsma's user avatar
0 votes
0 answers
29 views

Template includes

I want to use custom template redirects for urls such as http://example.com/foo and http://example.com/foo/bar I'm using add_rewrite_rule function for this add_action('init', function() { ...
Alexey Galkevych's user avatar
1 vote
1 answer
527 views

how to block direct access to multiple thank you pages?

I have multiple contact forms in my wordpress website and have a different thankyou page for each. So, i want to prevent direct access of thankyou pages by just entering urls. I want if the user fills ...
Ujjawal Poonia's user avatar
-1 votes
1 answer
132 views

Redirect to a subdirectory frontpage using without using a WP plugin- what files to edit, and how?

My situation I have a multisite setup, where I use subdirectories for different languages. I use the main homepage for English and subdirectories for other languages, as follows: mywesbite.com : ...
yarimoto's user avatar
  • 103
0 votes
0 answers
553 views

Polylang will not allow changing of language without translation

I am using polylang plugin to translate a website which uses custom theme. We are using custom post type. We want to use custom translation for that post type. We will not use polylang to translate ...
Latif Pala's user avatar
0 votes
1 answer
2k views

WooCommerce – template_redirect if is_checkout AND order has been paid?

In my WooCommerce store I would like to redirect to a custom 'thank you page' after payment has been completed. I'm using this code: add_action( 'template_redirect', 'myfunction' ); function ...
Jussi's user avatar
  • 23
0 votes
1 answer
202 views

How to customize file path for 404 redirection in php?

I made a plugin with a custom post type postcard. Most of postcards are private. I would like to redirect the logged out user in a specific php file inside my plugin instead of the 404.php or achive....
J.BizMai's user avatar
  • 820
0 votes
2 answers
129 views

Redirect user to a custom url after logged in

I'm using "Passwordless Login with OTP / SMS & Email - Facebook Account Kit" for login. I want to redirect user to http://www.domain.com/author/<username>/screen after they log in this is ...
Dreammedia Rulz's user avatar
0 votes
1 answer
470 views

wp_enqueue_style on template_redirect level?

I am using the following function, which works fine, in order to provide a minimal output of HTML at a WordPress installation of mine: add_action( 'template_redirect', 'test' ); function test() { ?&...
JohnnyBratsoni's user avatar
1 vote
1 answer
259 views

How to redirect (301) trashed post to it's parent taxonomy TERM ARCHIVE instead of 404 page

I have a taxonomy called "Sports", that includes terms: Football, Rugby, Tennis... What I want to achieve is when (for instance) a post that has the term football is trashed and a visitor try access ...
Charaf Web's user avatar
0 votes
1 answer
1k views

Custom URL routes

I'm a newbie in Wordpress, so excuse me if I ask a noob question. I want to redirect some of the URLs to a specific page (single-deal.php). Now, these set of URLs (regex provided for these URLS) does ...
Praful Bagai's user avatar
0 votes
1 answer
25 views

Internal redirect from page to category

I want to implement a page, let's say /today-deals that will show all posts under today category, like if we were navigating to /category/deals-for-october-31-2018 but without changing the URL.
Javier Marín's user avatar
0 votes
1 answer
1k views

Redirect to first child in menu

I have the following page hierarchy: Page Grandparent (This page) Page Parent 1 (Should direct here) Page Parent 2 Page Child Page Child Page Parent 3 Page Parent 4 My parent and child pages have ...
Sam's user avatar
  • 2,106
1 vote
1 answer
454 views

Custom pagination structure

Currently my pagination works like http://example.com/city/usa/ #for page 1 http://example.com/city/usa/page/2 http://example.com/city/usa/page/3 ...and so on I want to change ...
Parixit's user avatar
  • 133
1 vote
1 answer
14k views

Redirect the single product page link to the shop page

I am using the WooCommerce plugin. I want to redirect the user to shop page if they try to access the product link. For example, this is the product link: http://www.example.com/product/av and shop ...
Himani's user avatar
  • 37
0 votes
3 answers
2k views

How to redirect home page to another page after login for all user?

How to change home page to another page after login for all user roles, not a specific one?
Jalees Ahmad's user avatar
0 votes
1 answer
77 views

wp-admin redirects to standard wordpress page

I installed a Wordpress theme (NRGhost). It installs a plugin to use shortcodes (NRGhost Plugins) and other features. The plugin creates a custom redirect on wp-admin and redirects it to a custom ...
arximughal's user avatar
0 votes
2 answers
464 views

redirect_to not Including Hashtag from URL

When non-logged-in users attempt to go to a forum topic that requires a login, I'm trying to redirect them to that topic after they've logged in. But I can't seem to get the anchor/hashtag to remain ...
Sinclair's user avatar
0 votes
1 answer
4k views

How to override a query and display specific page by ID?

I need to build a offline page and first idea was to simply get desired page ID and do wp_redirect but that leaves a URL of the page to redirect to. function _action_offline_mode( $template ){ ...
Benn's user avatar
  • 1,023
1 vote
3 answers
3k views

force download a file in template_redirect hook

in my functions.php file I've added a custom action for the template_redirect hook which must force download a file stored on the server. The code of the download works fine when it is in a simple PHP ...
superfive33's user avatar
1 vote
0 answers
641 views

Redirect custom post type category to other custom post type category

Two similar custom post types have been created by my theme and a plugin I'm using. These basically customizing the categories post type. They are as follows: product-category listing-category I am ...
acctindie's user avatar
5 votes
1 answer
8k views

stop redirection on /wp-admin call to /wp-login

I am building a website, with wordpress+buddypress (latest version). In this website, I have my own custom login|signup|resetpass forms, and i do not want to link them to back-end wp-forms. And I ...
Poofy's user avatar
  • 69