On my webshop I have to see a button with a link to ad pdf file. For every product that button need to have a different link and a different button title name.
I built the webshop with woocommerce where I used Advanced Custom fields to show the buttons with a pdf link. In ACF I used a link array. On the product page I can change the title text of the link manually.
But. There are more than 1000 products. So it's not possible to do this manually. I imported a csv with the right header names. And importing the columns with links to the buttons works properly.
In the php code I used this standard acf code:
<?php
$link = get_field('link');
if( $link ):
$link_url = $link['url'];
$link_title = $link['title'];
$link_target = $link['target'] ? $link['target'] : '_self';
?>
<a class="button" href="<?php echo esc_url( $link_url ); ?>" target="<?php echo esc_attr( $link_target ); ?>"><?php echo esc_html( $link_title ); ?></a>
<?php endif; ?>
So, what meta data I have to give in my csv file to fill in the link title? --> The title on the button.
On my webshop I have to see a button with a link to ad pdf file. For every product that button need to have a different link and a different button title name.
I built the webshop with woocommerce where I used Advanced Custom fields to show the buttons with a pdf link. In ACF I used a link array. On the product page I can change the title text of the link manually.
But. There are more than 1000 products. So it's not possible to do this manually. I imported a csv with the right header names. And importing the columns with links to the buttons works properly.
In the php code I used this standard acf code:
<?php
$link = get_field('link');
if( $link ):
$link_url = $link['url'];
$link_title = $link['title'];
$link_target = $link['target'] ? $link['target'] : '_self';
?>
<a class="button" href="<?php echo esc_url( $link_url ); ?>" target="<?php echo esc_attr( $link_target ); ?>"><?php echo esc_html( $link_title ); ?></a>
<?php endif; ?>
So, what meta data I have to give in my csv file to fill in the link title? --> The title on the button.
Share Improve this question edited Oct 30, 2019 at 7:15 Jacob Peattie 44.2k10 gold badges50 silver badges64 bronze badges asked Oct 28, 2019 at 21:53 NielsD4NielsD4 11 Answer
Reset to default 0If you make a var_dump() on $link:
var_dump('<pre>', $link);
then you will see all array keys and you can choose the one you need.