0

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?

2
  • Are you in control of the templates? You could just replace the permalink function with the custom field. Commented 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. Commented Nov 29, 2019 at 6:19

1 Answer 1

0

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.

1
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.