Support

Account

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