- This topic has 3 replies, 2 voices, and was last updated 4 years, 10 months ago by
David.
-
AuthorPosts
-
May 16, 2021 at 8:15 am #1782988
Eric
Hi, I’m trying to create a custom template for my FAQ pages, specifically for FAQs that are related to a woocommerce products. I’m using this plugin for the FAQ pages: https://wordpress.org/plugins/ultimate-faqs/
My goal is to have FAQ pages for my products that have the product title, the main product photo, a link to the product page and link to a page containing all questions for the product.
I was hoping there was a fairly easy way to do this with the dynamic data and dynamic content options recently added. I looked at it for a while and I’m pretty lost. Would I need to add post meta to the FAQ pages to associate it with the product?
Thanks for helping me become unconfused 🙂
May 16, 2021 at 10:57 am #1783196David
StaffCustomer SupportHi there,
first off the Dynamic Data options in GPP 2.0 doesn’t support Woocommerce ( or any 3rd party plugin templates ) at this time. So you wouldn’t be able to use them for Woo meta data.
Secondly you would need some interface to associate the FAQ plugin with the Product ID. The simplest method would be to create a shortcode that you can add to the FAQ page and add the ID to. This does require Custom Development – which falls out of our scope… but as a simple pointer i cobbled this together from other PHP Snippets i had:
add_shortcode( 'woo_product', function( $attr ) { // Set shortcode args to accept ID of product extract( shortcode_atts( array( 'id' => '', ), $attr ) ); // Load ID value $product_idy = $attr['id']; $html = ''; // Check if produt ID exists if (wc_get_product($product_idy)) { // Create new instace of product $newWC = new WC_product($product_idy); // Get Prouct title and image $title = $newWC->get_title(); $image = $newWC->get_image($size = 'shop_thumbnail'); // Set up HTML $html = '<h2>' . $title . '</h2>' . $image; } return $html; });You can then use a shortcode like this:
[woo_product id="20"]… this should return the HTML for the title as H2 followed by the shop thumbnail image.May 17, 2021 at 3:50 pm #1786236Eric
Thanks for the starting point. Cheers!
May 18, 2021 at 2:32 am #1787147David
StaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.