• Resolved samjolley

    (@samjolley)


    I’m using WordPress 4.1.1, Genesis 2.1.2, and the Magazine Pro Child Theme. Here’s the site.

    Here’s a product post type example I’m working on.

    Right now I’m using 2/3 and 1/3 divs to create an “image column” and “content column”. Is there any way to use custom fields and css to auto-populate the post?

    Maybe add multiple featured images that get output into the 2/3 “featured images” div, and then a custom field for the product info that gets output into the 1/3 “product info” div.

    So I’d need featured images/fields for the product images (scrollable column), product category, title, price, and content.

    Here’s the post editor content I’m using right now:

    <div class="two-thirds first">
    Insert Large Images Here
    </div>
    
    <div class="one-third"><a href="insert category url here" target="_blank">Category</a>
    <h1>Product Title</h1>
    <h3>Price</h3>
    Product Info.
    <strong>Call for details (734) 516-9166</strong></div>

    Here’s a full screenshot of the product post type: Full screenshot

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    That would work, you’d be mainly altering your template to pull data saved in post_meta by using get_post_meta(). This is because you can’t enter PHP functions into post content. This would require that all posts be structured the same way, you would not have the ability to alter the content that deals with post meta.

    Another possibility besides altering your template would be to use a custom shortcode or multiple shortcodes to manage the output. Instead of entering boilerplate like you posted above, you could simply enter [do_it] (or whatever). The shortcode handler will pull the necessary data and place it in the boilerplate, then replace the shortcode with the actual content when the post is output.

    If you’re feeling adventurous in coding, instead of custom fields, you could use custom meta boxes. Then you can use targeted forms for the content instead of the generic custom field interface. The result is the same, but the form presented is more user friendly, and you could even code javascript to do some preliminary error checking, as well as use HTML5 file selector dialogs, etc.

    Thread Starter samjolley

    (@samjolley)

    Great ideas, thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom Fields to Populate Custom Post Type’ is closed to new replies.