-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display SVG in front end (Question) #7
Comments
Hi @Fortyfive, We are using a function in front to display all SVGs and of course also the retrieved icon from the svg selector : As the classname representing the SVG icon is fully retrieved, we must take off the
Does it sounds good for you ? |
Thanks Maxine! I’ll give this a go…
David
From: Maxime CULEA <[email protected]>
Reply-To: BeAPI/acf-svg-icon <[email protected]>
Date: Friday, 6 October 2017 at 10:21
To: BeAPI/acf-svg-icon <[email protected]>
Cc: David Hedley <[email protected]>, Mention <[email protected]>
Subject: Re: [BeAPI/acf-svg-icon] Display SVG in front end (Question) (#7)
Hi @Fortyfive<https://github.com/fortyfive>,
We are using a function in front to display all SVGs and of course also the retrieved icon from the svg selector : bea_the_icon( str_replace( 'icon-', '', $icon ) );
As the classname representing the SVG icon is fully retrieved, we must take off the icon- part. The following helper already handle it :
<?php
/**
* Get the theme's icon display depending on given type
*
* @var string $type
*
* @author Maxime CULEA
*
* @param $type
*
* @return string
*/
function bea_get_the_icon( $type ) {
return sprintf( '<svg class="icon icon-%1$s" aria-hidden="true" role="img"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-%1$s"></use></svg>', esc_attr( $type ) );
}
/**
* Display the theme's icon display depending on given type
*
* @var string $type
*
* @author Maxime CULEA
*
* @param $type
*/
function bea_the_icon( $type ) {
echo bea_get_the_icon( $type );
}
Does it sounds good for you ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#7 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAWSgqCGKF0AT1cBqocq8y0O58R-yPeZks5spfEMgaJpZM4PwLuy>.
|
Sorry Maxine, I still seem to be struggling. I cannot seem to get the syntax correct that appears in the page template to display the chosen icon. How do I add the ACF field name? |
Please have look to official documentation : https://www.advancedcustomfields.com/resources/get_field/ |
Thanks Maxime.
From: Maxime CULEA <[email protected]>
Reply-To: BeAPI/acf-svg-icon <[email protected]>
Date: Friday, 6 October 2017 at 12:50
To: BeAPI/acf-svg-icon <[email protected]>
Cc: David Hedley <[email protected]>, Mention <[email protected]>
Subject: Re: [BeAPI/acf-svg-icon] Display SVG in front end (Question) (#7)
Please have look to official documentation : https://www.advancedcustomfields.com/resources/get_field/
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#7 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAWSgr1saDuGU456kBfYDZti4rukHFMlks5sphQAgaJpZM4PwLuy>.
|
Has anyone figured out how to display the selected icon for a custom field named say, I managed to show it as an |
Hey, I am unfortunately also having issues. The field populates but the resulting HTML just looks like this: The actual icon is not showing. |
Hi, I have managed to populate the select field but cannot seem to display the output on the front end. Are you able to provide an example? Thanks in advance...
The text was updated successfully, but these errors were encountered: