I have datasheets for each of my products, linked using an ACF Link field. I would like to create a ‘Datasheets’ page, which would be an archive of these ACF datasheet links. How might I go about creating this?
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
}
Thanks, I’ll give this a shot.
Are you looking for a simple page or you want something in the page that could offer you functionalities of a datasheet
I want to build a page that dynamically populates with links to all my products’ datasheets. So if I add a new product, and assign it a link to a new datasheet, I want this page to automatically add a link to this new datasheet.