• mae48

    (@mae48)


    Hi, I have a form provided with ID and Class…and I want them to call my product title using my function.php if possible.By the way, I want to make a dropdown, that’s why..

    How can I do that??here is my code..

    <label for=”promolist”>You selected this promo</label>
    <div class=”form-control” id=”promolist”>

    </div>

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    WooCommerce products right? You want the product titles to appear as a dropdown select field, yes? But not all titles I would think, so what distinguishes the products in this list? A product category? Tag? Some other meta field?

    Most of the code can be in functions.php, but unless there’s a filter to hook for the form HTML, something needs to be on the template, such as a template tag (function) that outputs the dropdown HTML. There’s a specific way to override Woo templates, what to do can be found in WooThemes’ knowledge base.

    In this template tag or function, first output the portion of dropdown HTML that doesn’t repeat, namely the <select> tag, and perhaps the first option that just reads “Select…”. Now make a custom query for published product posts restricted by whatever category, tag, field, etc. Loop through the query results and in each iteration output the <option> tag with appropriate attributes, the post/product title, and </option>. If you want the select field to reflect a previously saved value as the currently selected option, the WP select() function is a handy way to output the selected attribute.

    After the loop completes, output the closing </select>.

Viewing 1 replies (of 1 total)

The topic ‘Calling data to database’ is closed to new replies.