Support

Account

Home Forums General Issues How to create archive page of ACF fields Reply To: How to create archive page of ACF fields

  • I can’t give you specifics, only a general idea.

    First you need to create a new rewrite rule in WP, for example if you want to have something like http://yoursite.com/product/PRODUCT_NAME/datasheets The rewrite rule would be almost identical to the existing rule for the product and it would load the same template https://codex.wordpress.org/Rewrite_API/add_rewrite_rule. You’d also need to add a variable for “datasheets” so that you can check it later.

    The rewrite rule would look something like (and this is only a guess):

    
    add_rewrite_rule('^product/([^/]+)/datasheets/?$','index.php?product=$matches[1]&datasheets=1','top');
    

    documentation for adding the query_var can be found here https://codex.wordpress.org/Plugin_API/Filter_Reference/query_vars

    Then, in the single product template file you’d need to check for the value, something like this

    
    $datasheets = intval(get_query_var('datasheets', 0));
    if ($datasheets) {
      // show the datasheets
    } else {
      // show something else
    }