Using the page builder, is it possible to a table query using PHP in the Code Block? I have a table with products and want to use an Ajax form to query and display them on a page. I tried a code sample:
global $wpdb;
$wp_products = $wpdb->get_results(“SELECT * FROM catalog;”);
echo “<table>”;
foreach($catalog as $catalog){
echo "<tr>";
echo "<td>".$wp_products->ITEM."</td>";
echo "<td>".$wp_products->DESCRIPTION."</td>";
echo "<td>".$wp_products->COLOR."</td>";
echo "<td>".$wp_products->TYPE."</td>";
echo "</tr>";
}
echo "</table>";
Is this possible? Any recommendations on how to implement this on a page? - I did try putting the <?php> tags, but no go.
Hi!
No, thats not possible out of the box. The code block element only runs HTML, CSS and JavaScript. There are some plugins that can help you with that however, take a look:
https://wordpress.org/plugins/insert-php/
Regards,
Josue
So are you saying not to use the Code block? Can I use the Insert PHP with the code block? Am I stuck using generic page elements and not the Avia layouts?
No, most Avia elements are able to run shortcodes (Insert PHP uses this), try using a Text Block if it doesn’t work with a Code Block.
Best regards,
Josue
Hey!
Please update to Enfold 2.9.1. It should also support shortcodes in the “Code” elemement and then you should be able to use it with the insert_php shortcode like here: http://wamitag.com/Dev_2/?page_id=10
Best regards,
Peter
Please close this Dude, I think I’m going to use WooCommerce to manage the products.