Home › Forums › General Issues › Use Custom field to show an article › Reply To: Use Custom field to show an article
Hi @hummelmose
Thanks for the clarification. This is how I would do it.
Add an action to the wp
action. This action is run when WP is ready to function.
Look at the URL (find the url in the $_SERVER
array) and check if the url follows your above pattern. You can check for a patern with regexp.
After the matching is done and you have a variable holding the $article_id, your next step is to find the post that has a matching custom field value.
You can query the WP posts with teh get_posts function as shown here:
http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/
Then, once you have the $post object, you can redirect to it like so:
wp_redirect( get_permalink( $post->ID ) );
exit;
I hope the above makes sense. You may need to get some help from a PHP / WP dev if you can’t get it to work.
Good luck mate.
Cheers
E
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.