P
P
Parrot2232021-09-14 18:02:44
WordPress
Parrot223, 2021-09-14 18:02:44

Counter in php for issuing files from a directory?

There are about a dozen of these cards. There is a separate file for download for everyone. Cards appear through a cycle in wp custom fields, and in this case, only one file can be registered as an absolute. You need something like counter-increment in css - so that the file is pulled from the folder in order for each of them. Maybe you can do without php? Thanks for answers.
6140b970e258c783727247.png
6140b9766be50625532715.png

<a href="<?php echo esc_url( get_template_directory_uri() ); ?>/hhhh/1.pdf" class="about-item__btn btn" download></a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2021-09-14
@Parrot223

Maybe you can do without php?

How do you plan to do without php if WP is written in php and you need to increment the value to get the file.
Cards appear through a loop in wp custom fields

You need to initialize the variable outside of the loop. For example. $i = 0;
Then, inside the loop, you need to increment the variable $i++;
Well and substitute the value of the variable in the field
Something like this:
<a href="<?php echo esc_url( get_template_directory_uri() ); ?>/hhhh/<?php $i.'.pdf'?>" class="about-item__btn btn" download></a>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question