php functie in add_shortcode
-
Hoe maak ik van deze PHP-snippet een bruikbare WordPress-shortcode. De php code werkt wel in functions.php van mijn thema, maar ik wil graag een bruikbare shortcode die ik in Gutenberg editor kan gebruiken.
Dit is de code waarvan ik een shortcode wil maken. Alle suggetsies zijn welkom:function display_tracklist(){
global $product;// Get the tracklist field value
$custom_field = get_post_meta( $product->get_id(), ‘_product_attributes’, false );
// Display
if( ! empty($custom_field) ){
$tracks = $custom_field[0][‘Tracklisting’][‘value’];
echo ‘<span class=”track”>’ . nl2br($tracks) . ‘</span><br>’;
}
}
1 reactie aan het bekijken (van in totaal 1)
1 reactie aan het bekijken (van in totaal 1)
- Het onderwerp ‘php functie in add_shortcode’ is gesloten voor nieuwe reacties.