Last active
August 14, 2018 14:11
-
-
Save benfavre/560f265b7a56727b186864a4ea29c7e4 to your computer and use it in GitHub Desktop.
Shortcode WordPress PODS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function productsList () | |
{ | |
ob_start (); | |
// On commence un "buffer" ici pour | |
// capturer le contenu qui va sortir de la fonction | |
$params = array( | |
'limit' => 20, | |
'order_by' => 'menu_order', | |
'page' => 1 | |
); | |
// On lance la requète pods | |
$products = pods ('products', $params); | |
?> | |
<div class="list-form-entries"><?php | |
// On boucle | |
while ($products->fetch ()) { | |
?> | |
<div class="list-form-entry"> | |
<div class="title-bloc"> | |
<h3><?php echo $products->display ('name'); ?></h3> | |
</div> | |
<div class="deal-details"> | |
<?php echo $products->display ('post_content'); ?> | |
</div> | |
</div> | |
<?php | |
} ?> | |
</div><?php | |
// On ferme le buffer et on met le contenu dans la variable $output_string | |
$output_string = ob_get_contents (); | |
ob_end_clean (); | |
// On envoi le contenu au shortcode | |
return $output_string; | |
} | |
add_shortcode ('products', 'productsList'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment