Support

Account

Home Forums General Issues Display fields based on parameters in URL Reply To: Display fields based on parameters in URL

  • 1) You supply the post ID or the post to get the fields from. All ACF functions allow you to do this https://www.advancedcustomfields.com/resources/get_field/

    2) You get the parameter from the URL in the template. How you get this value depends if/how you set up WP to handle them and what the URL will look like exactly.

    For example, using a simple $_GET value http://somesite.com/page/?agent=1

    
    $post_id = false;
    if (isset($_GET['agent'])) {
      $post_id = intval($_GET['agent']);
    }
    

    It gets more complicated from there, for example you can create pretty URLs using rewrite rules and adding url parameters.
    https://codex.wordpress.org/Rewrite_API/add_rewrite_tag
    https://developer.wordpress.org/reference/functions/add_rewrite_rule/
    https://premium.wpmudev.org/blog/building-customized-urls-wordpress/