I am trying to populate a single text field based on a php webpage. Basically I have a database of products that display on a page using php, when you click a product it will then go to that product page. It is only product information and all I am trying to do is grab the product title so that when I add the single form to all product pages, it will grab the product title from that specific page.
The code that it is using to populate this field is:
<?= $product['Title'] ?>
I have created a dynamic parameter called populate_product
I then added a filter to the php which just caused a critical error so I know I am doing something wrong. I honestly have very little coding knowledge so I am basically just winging it here. Would hugely appreciate any help.
If you are using a custom DB or a custom table, you should also be able to use Populate Anything to get data into the required field with the database object.
You can use the {embed_post:post_title} merge tag as “Default Value” for a single line text field. When the form is embedded in a single post or page, the post title will populate that field. The merge tags available for the post are explained here:
I just set up a field in a form like that (here’s a screenshot):
I appreciate the response guys, the problem is that its not a post that I am trying to get the title from. Its a custom PHP page that grabs information using a custom API. The data is populated from an outside source and not a post or product in wordpress. This is the reason I need to try and grab <?= $product['Title'] ?>.
I have replicated what you both have done, the problem is I need to grab a specific piece of text from the page. It is a product title which has the class “product-title”. Is there any way I can auto-populate a field based on a class on a page?