Redirect Post to Custom Field Link

I use Page Links To a lot. Probably on every website I’ve built for the last five years.

Recently, I ran into an issue where a conflict was preventing the URLs from saving using Page Link To, and I needed to come up with an alternate solution.

I stumbled across this function, that can setup an entire Post Type to redirect to a custom field value, and I think that’s what I’m looking for.

Here’s a modification that can be placed anywhere and grab custom field info (using ACF). I ended up with a Page Links To similar function, without having to use an additional plugin.

$url = get_field('resource_url');
if( $url ) {
	wp_redirect( $url );

Leave a Reply

Posted in php
katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.