0

Sory for the complete newbie question but after 2 days struggling:

I have made a custom post called cars in Worpress with a plugin that adds numerous specs for cars that are for sale. The specs are in custom fields, such as price, make, model etc. I want to use a shortcode [showdetails] to display a table with these specs.

When i paste the table directly into a custom post single-cars.php like this it works.

    <p>     <label>Prijs:</label> </br>
        <input type="text" name="prijs" value="<?= @$custom["prijs"][0] ?>" class="width33" />  </p>

How do i get this table to display with a shortcode [showdetails]

I now have

<?php
function showdetails_shortcode( $attr, $content = null ) {
    return '<table> <tr> <th>Prijs Component</th> <th>Bedrag euros</th> </tr>
 <tr><td>Prijs</td> <td></table>';
/********This shows the start of the table, but now the cell with the custom field... *********************

 <tr> <td><?php $key="prijs"; echo get_post_meta($post->ID, $key, true); ?></td> </tr>

**************************************************/ 
</table>
}
add_shortcode('showdetails', 'showdetails_shortcode');
?>

This works but as soon as i (think) i call the value of a custom field it all goes wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.