Support

Account

Home Forums General Issues Database

Solving

Database

  • Can I pull the custom fields from the database?
    I only use the wordpress to be the administrative page, but the site I use to display the database generated by wordpress.

    `<?php
    $mysql = new sql();
    $post_name = $_GET[‘id’];
    $sql = $mysql->query(“SELECT * FROM wp_posts WHERE post_name = ‘$post_name’ LIMIT 1″,”mktiscom_cms”);
    $result = $mysql->fetcharray($sql);

    $post = $result[‘post_content’];

    ?>
    <h1><?php echo utf8_encode($result[‘post_title’]); ?></h1><br>
    <p><?php echo utf8_encode(nl2br($post)); ?></p>`

  • You custom field data is saved into the database just like any postmeta value… mostly. Fields on options pages, repeaters and some other places are stored differently or in other places.

    If you’re going to bypass WP for showing the front end then I’d suggest digging through the database to see how all of your fields are stored and where. Doing a search using phpMyAdmin on you field name will get you to the areas you need to look at.

    Is there a particular reason why you completely bypass WP on the front end?

  • I found my custom field in the database with this code

    `<?php

    $mysql2 = new sql();
    $post_id = $_GET[‘id’];
    $sql2 = $mysql2->query(“SELECT * FROM wp_postmeta WHERE meta_key = ‘_campoadd’ LIMIT 1″,”mktiscom_cms”);
    $result2 = $mysql2->fetcharray($sql2);
    ?>

    <p><?php echo utf8_encode($result2[‘post_id’]); ?></p>
    <p><?php echo utf8_encode($result2[‘meta_key’]); ?></p>
    <p><?php echo utf8_encode($result2[‘meta_value’]); ?></p>`

    however my custom field is an image, and al so have the field data.(http://mkt-in.com.br/home/noticia2.php?id=marcenaria-piracicaba) Know how the image q can assign this field?

  • Images are always stored as the ID value. So the meta_value will be the ID of the post attachment containing your image.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Database’ is closed to new replies.