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
}
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.