Questions tagged [template-redirect]

The tag has no usage guidance.

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

Want To Redirect Pages on 2nd site to the posts on 1st site {both have same permalink structure

I used Below Code which is helpful In Redirecting all categories post to other site add_action('template_redirect', 'post_redirect_by_custom_filters'); function post_redirect_by_custom_filters() { ...
0
votes
1answer
22 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 ...
1
vote
2answers
51 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 ...
0
votes
0answers
22 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() { ...
0
votes
0answers
14 views

template_redirect hook sending wp_mail twice

I have a few restricted pages. If a user tries to access those, I warn them by email using wp_mail and alert admin with some data such as username, URL, time, etc. For that, I am using the ...
0
votes
0answers
12 views

wp_redirect function is not working

I am using this code to redirect. I am using these lines of codes in the template file. $url = 'example.com/mijn-profiel/'; wp_redirect($url); exit(); What should I use to do it to make it happen?
0
votes
0answers
19 views

Redirect page during a weekly time interval

I have a registration page 'register' which sends information to a third party server as part of a dual registration process. The 3rd party have a 2 hr weekly maintenance schedule every Friday 9-11pm ...
1
vote
1answer
87 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 ...
0
votes
0answers
46 views

Woocommerce Cart content disappear when update quantity after implementing url restriction with wp_get_referrer

I'm trying to restrict my users from accessing the cart with a direct url "/cart" as users need to register for an event before they are directed to cart. I had implemented the page restriction with ...
-1
votes
1answer
38 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 : ...
0
votes
0answers
149 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 ...
0
votes
0answers
29 views

All pages redirecting to homepage

All links on my site are redirecting to homepage. WPDev-Redirect-Trace-01: /home/domain.com/public_html/wp-includes/canonical.php : 607 wp_redirect("https://www.domain.com/",301) WPDev-...
0
votes
1answer
377 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 ...
0
votes
1answer
53 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....
0
votes
2answers
43 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 ...
0
votes
1answer
64 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() { ?&...
0
votes
1answer
103 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 ...
0
votes
1answer
202 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 ...
0
votes
1answer
18 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.
0
votes
1answer
782 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 ...
1
vote
1answer
223 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 ...
1
vote
1answer
8k 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 ...
0
votes
3answers
1k 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?
0
votes
1answer
62 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 ...
0
votes
1answer
191 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 ...
0
votes
1answer
2k 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 ){ ...
0
votes
3answers
2k 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 ...
1
vote
0answers
277 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 ...
3
votes
1answer
4k 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 ...
1
vote
1answer
363 views

wp_redirect on base wp-admin and login

UPDATE: I've done some more research on my problem and have narrowed down the problem further. The question below has been very rewritten from the original. I'm trying set up a plugin to redirect ALL ...
0
votes
0answers
535 views

Force CSV download with template_redirect

I'm struggling to get a dynamically-generated CSV to download with a template_redirect. It seems to work (if not this exact version, another similar version) when it does not go through Wordpress, e.g ...
0
votes
1answer
521 views

template_redirect() doesn't seem to be working

kind of a rookie question but here goes: I'm working on a Wordpress theme from scratch on my local machine, and I'm setting up a static page for the Blog. I have my archive.php file for all the posts ...
1
vote
1answer
279 views

Setup template_redirect using has_term when NO term assigned

we have a redirect function for a Custom Post Type to redirect single view pages for certain terms back to their archive landing page. There should only be single view pages for one specific taxonomy, ...
0
votes
1answer
42 views

how to show post content with post name in sidebar?

I started working on a wordpress website, I need to show 20 words from every post with post name in Sidebar. I am new to wordpress, I am finding difficult to do it.
1
vote
0answers
1k views

How do I determine what is causing a redirect for a given page?

This is probably a face palm question. On Wordpress 4.4. the link http://example.com/blog ...redirects to: http://example.com/category/general ...ie. it's redirecting to archive.php and ...
5
votes
1answer
6k views

How do I redirect /search/ to wordpress search template?

I have a typical Wordpress site, with a typical Search page template set up which uses the typical GET format <form id="searchform" action="http://example.com" method="get"> <...
1
vote
0answers
51 views

Why does my URL rewriting only work using two different methods?

For our website, I've built out some "pages" using URL rewriting, with some code that I found here. It worked to have two of these special pages, but it's not working when I try to add a third. I've ...
-1
votes
1answer
1k views

redirect not logged in users to specific page and redirect them back where they come from

The problem is not the first redirection (already solved in other case here), the problem is the second redirection back. No problem with the first redirection, when no logged in user come to page ID ...
0
votes
0answers
134 views

How to identifty post from its URL in 404 page?

Why GUID is such unstable? Some of the post's GUID are pretty permalinked, but most of them are default. I's using Pippin's function to get the post_id from its GUID, but it's not working if my site ...
0
votes
1answer
289 views

Template Redirect to /2015 to use page template

We work with non-profits and come across this issue a lot. We need to use a page template for the url structure domain.com/2015 where we'll be adding an "end of year" report. We're not using the ...
1
vote
1answer
688 views

How to pass a message using template_redirect

I'm using the following function to redirect a post to another using custom field. It's working just fine until I added the line#8 to pass an ID so that I can grab it in to the post (to where was ...
1
vote
0answers
45 views

Redirect on Empty Query Var [duplicate]

I have a plugin with two rewrite rules: public static function cp_libdatabases_add_rewrites(){ $options = get_option( 'libdatabases_plugin_options' ); $staff_url = $options['staff_url']; ...
0
votes
1answer
485 views

How to check if the user was redirected?

I need an advice on how to the following: I have registered course custom post type and created one for example Course1. Course1 has child posts - some are private (e.g Lectures) and some are not. ...
0
votes
1answer
1k views

template_redirect to accompany with a shortcode

In one of my plugin's shortcode I'm handing user login / registration on the fly with a post submission. So the whole thing is happening within the shortcode like: <?php function this_shortcode() {...
1
vote
1answer
177 views

URL rewriting with custom user meta “/%shop_name%/gallery/%gallery%”

I have created a custom user meta = shop_name in User Profile and custom post type gallery The default URL of the post is http://localhost/gallery/%gallery% which i have modified to below given URL ...
0
votes
1answer
2k views

how to load posts to a custom post template after using template_redirect or template_include

I need to use the URL parameter ?m=1 to load every page of my wordpress with a different template but the problem is that I can't pull the text and posts that can be accessed using the canonical URL I ...
1
vote
1answer
1k views

Force HTTPS 301 redirect with hook

I am trying to force a 301 https redirect with hooking into the 'template redirect' function. I want not doing it a htaccess because when I update my permalinks, htaccess with https redirect ...
0
votes
1answer
324 views

Redirect not logged in users if they are on a specific page and category

Following code is working fine for pages but how to add category id as well with pages in the following code. add_action( 'template_redirect', function() { if ( is_user_logged_in() || ! is_page() )...
0
votes
1answer
461 views

Template_redirect for child custom post types

I currently have a custom post type called 'Services' which has two levels (parent and child). I need to load three different templates within this post type (1 for the parent, and two different ones ...
0
votes
0answers
417 views

template_redirect and title

I pass a template_redirect in wordpress as hook but I want to have a personnalized title for this page and I miss to do that. Has someone any idea ? add_action( 'template_redirect', 'virtual_pages' );...