Questions tagged [template-redirect]
The template-redirect tag has no usage guidance.
104
questions
0
votes
1
answer
21
views
Not displaying the wp_query object for the following code in the frontend
add_action('template_redirect', function () {
global $wp_query;
echo '<pre>';
print_r($wp_query);
echo '</pre>';
die;
});
0
votes
1
answer
11
views
Where does the redirect from shortlink to permalink happen?
When requesting short urls they are redirected to their matching permalink, for instances :
shortlink
permalink
/?cat=category_id
/category_base/category_slug
/?p=post_or_page_id
/custom_structure/...
0
votes
2
answers
80
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 ...
0
votes
1
answer
669
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 ...
0
votes
1
answer
294
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 ...
0
votes
1
answer
68
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 ...
0
votes
1
answer
173
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 ...
1
vote
2
answers
421
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 ...
0
votes
1
answer
180
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 ...
1
vote
0
answers
69
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 ...
0
votes
1
answer
127
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 ...
1
vote
0
answers
42
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/...
1
vote
1
answer
157
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 ...
0
votes
0
answers
70
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:
...
0
votes
0
answers
135
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 ...