• Hi,

    I’m trying to display the value of a custom text field in my theme’s single.php. So here’s the code I’ve added:

    <?php types_render_field("wpcf-price",array('output'=>'html')); ?>

    It just does not work and the field is never displayed.

    Is this the right way to do this or do I have to use the embedded types features? Is there any thing I’m missing here?

    thanks,
    m

    https://www.ads-software.com/extend/plugins/types/

Viewing 9 replies - 16 through 24 (of 24 total)
  • Plugin Author Amir Helzer

    (@amirhelzer)

    Should be:

    <?php echo(types_render_field("vineyard", array("show_name"=>"true","output"=>"html"))); ?>

    Actually, what’s the correct official way to DISPLAY IN A THEME the custom field?

    This should be item no.1 in the FAQ on this plugin page, yet isn’t. I shouldn’t need the Views plugin to display simple custom fields. Please include a one-liner, at least, in all your documentation, including FAQ here on the plugin page, about how to SHOW the custom fields in the themes.

    Thx

    This plugin has the CREPPIEST explanation ever about how to use it all!
    Guess it was done on purpose? Cause I cannot think of anything else ..

    I could not find ONE single line in the FAQ about HOW on Earth could one display these custom posty types & taxonomies on the page! Is this not all that is all about, dear authors?

    So for this, this plugin did not earn even one single star – it’s simply useless, and makes people waste time on it for nothing …

    candy2012, I suspect the gap in the documentation is because programmers often forget that people don’t know the basic concepts which the programmers learned long ago. In this case, the basic methods of how to make the data be displayed automatically are not documented where we’re looking.

    How to manually make data appear is documented, but it’s outdated. One of the example pages shows fields being created, and the field editing page includes the shortcodes needed to display the data. The current version of Types has replaced that with a Types shortcode generator (an icon at the top of the edit page, in the same row as the image-insertion icon).

    But inserting a shortcode in the same post which contains the data is only useful in some situations (ie, providing a fill-in-the-blanks tool so someone doesn’t have to edit some messy HTML). How to make a certain custom post type emit data automatically is not pointed out — at least not well enough. Even in the “Views” documentation, they seem to show how to make a page emit data from Types, but I haven’t noticed a way to define how a custom post type should be displayed.

    For example, if custom posts are searchable, a search result should find the single entry for a specific house or magazine article (using their Realty and Magazine examples). But how to define the default display for that custom post type is not apparent. We who haven’t yet tried it can hope that is because there is an admin menu option which makes such definitions obvious. But it’s hard to decide on what technology to use in a site if the needed details are hard to find.

    The Views PHP Integration document does say:
    “Function ‘render_view’
    Renders a view and returns the HTML output.”
    That’s fine and dandy for a WordPress programmer who knows where to use that. I know plenty of PHP, but for WordPress I know what “the loop” is for, that there seems to be something “single” for posts, and how a plugin hooks in. If there are common places to use that PHP, it would help if those were mentioned.

    (Me, I’m pretty sure that I need Types and Views, but I’m waiting for a reply to a question related to subdomain sensitivity which was sent to them recently.)

    I’m not sure, but I think step 4 in the View Templates document is what connects a View template to a custom post type. The phrasing mostly can mean that, and I suspect that the image is trying to show a connection being made from a View to a custom post type. A better image would be one which shows the first item (post) with a certain View template already chosen, the second item (page) with that pulldown menu, and text indicating what I’m describing… so we who are trying to confirm our weak understanding can strengthen the certainty of understanding.

    Of course, that only helps those who are using the Views plugin, not those only using Types.

    I just tried what is in the Views Template document. That does let you define the appearance of a post of a certain type. If you previously used Types to define a custom post type (ie, vehicle or DVD), then you can attach a View template to that post type so when you look at the post it displays what you’ve defined.

    What is missing from that document is having to go back to Types > Custom Fields, edit the Types, and select that the Type should be displayed with this View Template (click Edit next to “Content templates:”). It seems to not be sufficient to select your custom post type in “Post Types:”. When you create a custom post, on the right side should be a pulldown menu to let you select your custom View Template. (EDIT: Hmm… that pulldown menu has also appeared on old non-custom post edit pages also.)

    That still doesn’t help a Types-only user to merge Types into their design or theme.

    @roamfree, @candy2012, @pkiula:

    what you want to look at is the types fields api. The example right at the top explains how to make a Types custom post type appear in your template without using Views.

    @badfun,

    Yes, that function is also mentioned near the top of this discussion. The documentation for the Types API says “To insert Types fields using PHP code, use the following syntax:” but gives no hint where to insert such code.

    The two hints in “Using Custom Fields” are shortcodes and Views. Shortcodes will only display what is in the current post (or is there a loop-post shortcode?). This discussion seems to be about Types — and not Views, which does provide ways to display what is in Types.

    Some of us can insert PHP in pages, but that’s not a general solution and is probably not what was intended. I suspect this does not belong in the loop either, but I’m not certain.

    @roamfree,
    The api is for adding the code to your page template, and yes it is in the loop (it’s a post type). I’ve been using it because it is a great way to make a custom post type really fast.

    Here is an example:

    <div class="content">
        <?php the_excerpt(); ?>
        <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'bfportfolio' ) ); ?>
        <p>URL: <a href="<?php echo types_render_field("project_url", array('raw'=>'true'));?>" target="_blank"><?php echo types_render_field("project_url", array('raw'=>'true'));?></a></p>
        <p>Design by: <a href="<?php echo types_render_field("project_design_url", array('raw'=>'true'));?>" target="_blank"><?php echo types_render_field("project_design", array());?></a></p>
    
        <?php wp_link_pages( array( 'before' => '<nav class="page-link" role="navigation">' . __( 'Pages:', 'bfportfolio' ), 'after' => '</nav>' ) ); ?>

    You can see that I’ve entered in a ‘project url’ and a ‘project design url’ metatype, just below the main content, which were set up in the custom post type. This is inside the query that looks only at my custom post type.

    Does that help?

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘[Plugin: Types – Custom Fields and Custom Post Types Management] render custom field in theme’ is closed to new replies.