WordPress.org

Forums

[resolved] Page/post *content* templates (14 posts)

  1. bardo
    Member
    Posted 3 years ago #

    Is there a way (or a plugin) to have content templates?

    On my website there are many similar pages, and the content always has the same structure. I want non-technical people to be able to insert content without messing with the structure, and having a template to modify would spare me many headaches...

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Why not create 1 or more custom templates in your theme?

  3. bardo
    Member
    Posted 3 years ago #

    Because custom templates are related to the structure of a page, not to its contents. I'm looking for content templates.

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    I think most of the plugins of this type tend to deal with very specific content - such as events etc. Have you thought about using custom fields for this content?

  5. bardo
    Member
    Posted 3 years ago #

    I did, and I found two major drawbacks: they would need html code to be directly input, and since they are not made for this, an entire paragraph would have to be put inside the field. This is not ideal to deal with non-technical users, it would complicate the matter even more.

  6. esmi
    Forum Moderator
    Posted 3 years ago #

    I'm not sure that there's going to be an easy answer to this one - short of parsing the content and applying the structure at the page generation point. The only thing I can suggest right now is moving this topic to the WP Advanced forum in the hopes that someone in there might have dealt with a similar issue in the past.

    Want to me to do that?

  7. bardo
    Member
    Posted 3 years ago #

    If you can, it'd be very nice of you :) Thanks a lot for answering!

  8. Jackson
    Member
    Posted 3 years ago #

    I think you need to explain or show what you mean by 'structure' of the content.

    For example, are you talking about formatting the content in a series of columns or table cells?

    Or are you talking about a format the authors should follow when creating their content, ie: Intro paragraph, followed by ordered list, followed by paragraph, etc.

    Custom templates can certainly control the output, and in turn - structure of your content and format however you like. I'm just having trouble understanding exactly what you're trying to achieve.

  9. bardo
    Member
    Posted 3 years ago #

    Thanks for answering, Jackson.

    I'm thinking more of the second kind, something like, for example:

    Content template -> "Product page"

    Fields to fill: product name (inserted in an <h1> tag, prepended by a "Buy: " string), product description (will end up in a <div> with a specific id or class), technical specs (comma/newline separated, will end up in a list with its own id/class...).

    Use case: the user selects the content template thingy and gets a form to fill, or at least a normal page editor screen, but pre-filled with sample data defined in the template.

    That's how I visualize it, it should not necessarily be this way, I just want to get the point across... is it clearer now?

  10. Jackson
    Member
    Posted 3 years ago #

    Well actually, Custom Fields + a Custom Template is what you need.

    You can roll your own meta boxes, or use a plugin like: http://wordpress.org/extend/plugins/custom-field-template/ to setup default custom fields for your users to enter on the write page screen.

    Then within your custom template you would pull in and format this content however you please. Psuedo code...

    ...
    <h1>Buy: <?php echo get_post_meta( $post->ID, 'product_name', true ); ?></h1>
    <div class="description">
        <?php echo apply_filters( 'the_content', get_post_meta( $post->ID, 'product_desc', true ) ); ?>
    </div>
    <ul>
    <?php
    $specs = get_post_meta( $post->ID, 'product_spec' );
    foreach( $specs as $spec ) {
        echo '<li>'.$spec.'</li>';
    }
    </ul>
  11. bardo
    Member
    Posted 3 years ago #

    Seems great, thanks! I didn't think custom fields could be processed that way... Thanks a lot, the example is really clear :)

  12. ladjzero
    Member
    Posted 3 years ago #

    I meet the same problem yet. I have tried such plugin as "custom-field-template" to guide users to input every necessary information. Like this:

    _______________
    | Book : _______|
    | Author :______|
    | Price :_______|
    |_____________|

    And then, I want to format the text above to HTML code and save as post-content, not "meta", because it would be very easily searched by users.

  13. Jackson
    Member
    Posted 3 years ago #

    Try a search plugin like http://wordpress.org/extend/plugins/search-everything/ which will search your custom fields.

  14. ladjzero
    Member
    Posted 3 years ago #

    Thanks Jackson.
    "search-everything" works perfectly!

    Maybe bardo wanted a plugin like http://www.advancedcustomfields.com/add-ons/flexible-content-field/ ,but it is not free. (It seems a great plugin that worth the price ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.