Feed image links via PHP: Wordpress

Asked

Viewed 33 times

0

to using a theme that currently has the portfolio option, but it does not natively offer an option to add link the added images.

Request to modify the file. PHP, but I can’t find a way to feed one image after another, because it’s assigning the same value to all in order to concatenate

Follow the commands:

ARRAY

$name = $arrayName = array (
'1' => 'https://google.com',
'2' => 'https://bing.com', );

Feed

<a href="<?php
for($i=0;$i<100;$i++){
echo $name[$i];}

I have tried several ways but all concatenate the links.

Result so far:

links aparentes

I realized that there is a variable $id where the id of the images is shown.

  • Don’t use the for within the attribute href. Use it this way, for example: <?php for (...) ?><a href="<?php echo $arr[$i]['href'] ?>"><?php echo $arr[$i]['text'] ?></a>

  • Oks, but regarding the development of the food code without concatenating, you have some idea of what it would be like ?

  • The way I commented, you would stop concatenating. I think your doubt is how to make the addition of link dynamically.

  • Yes, exactly, because I’m trying to assign a different link to each image

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.