I have a custom post type called "articles". When an article link is clicked, I want to redirect them to custom URL(this URL is saved in the database as custom field) instead of the single page. How can I do it? I couldn't find an action hook/filter for it?
-
Are you in control of the templates? You could just replace the permalink function with the custom field.– Jacob PeattieCommented Nov 29, 2019 at 4:57
-
@JacobPeattie No. I want to do this whole site. Archive pages, widgets, etc. Everywhere.... So this won't work and I don't like touch theme & plugin files for this purpose.– I am the Most Stupid PersonCommented Nov 29, 2019 at 6:19
Add a comment
|
1 Answer
For redirect to custom url you need to change post detail link to custom url. You simply remove post link and apply custom url.
<a href="<?php echo get_field('link'); ?>"><?php the_title(); ?></a>
In my case "link" is custom url.
-
I want to do this whole site. Archive pages, widgets, etc. Everywhere.... So this won't work and I don't like touch theme & plugin files for this purpose. Commented Nov 29, 2019 at 6:18