I have a custom template file containing some HTML tags and get_post_meta function. I want to insert the HTML data into post_content column. Is there a wordpress function or SQL function to save into post_content column? I couldn't find a good anwswer on the internet.
This is my custom template file.
<?php
// the post name is cryto name.
$cryto_name = get_the_title();
// Cryto Variables from SQL table
$ccf_company = get_post_meta( get_the_ID(), 'ccf_company', true );
$ccf_jurisdiction = get_post_meta( get_the_ID(), 'ccf_jurisdiction', true );
$ccf_symbol = get_post_meta( get_the_ID(), 'ccf_symbol', true );
$ccf_maximum_supply = get_post_meta( get_the_ID(), 'ccf_maximum_supply', true );
?>
<h2>Features of <?php echo $cryto_name ?></h2>
<figure class="ht-post__content table">
<table>
<thead>
<tr>
<th>Features</th>
<th class="has-text-align-center" data-align="center"><?php echo $cryto_name ?> (<?php echo $ccf_symbol ?>)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Developer</td>
<td class="has-text-align-center" data-align="center"><?php echo $ccf_company ?></td>
</tr>
<tr>
<td>Country</td>
<td class="has-text-align-center" data-align="center"><?php echo $ccf_jurisdiction ?></td>
</tr>
<tr>
<td>Symbol</td>
<td class="has-text-align-center" data-align="center"><?php echo $ccf_symbol ?></td>
</tr>
<tr>
<td>Max Supply</td>
<td class="has-text-align-center" data-align="center"><?php echo check_max_supply($db_coin_max_supply, $ccf_symbol) ?></td>
</tr>
</table>
</figure>
I already made a sql table and this template is working. However, I'm trying to save this HTML output into post_content column.
post_content
column but then you've also mentioned at the very end a custom SQL table, are you talking about updating the content of a post? Or updating a column in your custom table? If you're talking about updating a posts content then SQL is not the correct way to do it. Also, the code you're trying to modify to save the HTML as well as where the HTML is coming from is missing from your question. If it's the output of your template then saving that means it would be out of date when your meta values change, it would be much easier/faster to build a block in PHP