Site logo

[Resolved] Custom FAQ pages for product questions

Home Forums Support [Resolved] Custom FAQ pages for product questions

Home Forums Support Custom FAQ pages for product questions

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #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 🙂

    #1783196
    David
    Staff
    Customer Support

    Hi 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.

    #1786236
    Eric

    Thanks for the starting point. Cheers!

    #1787147
    David
    Staff
    Customer Support

    You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.