WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Custom fields shortcode] php include function + this plug in (2 posts)

  1. utunlimited
    Member
    Posted 5 years ago #

    Hi

    Hope you can help
    How can I write a html/css/php (whatever will work) that can be referenced by every page. I have written my own html file "cfields".

    This is in my page template
    <?php include("cfields.html"); ?>

    cfields.html

    <html>
    <head>
    </head>
    <p>Score: </p>[cf]score[/cf]
    </html>

    It gives:

    Score:
    [cf]score[/cf]

    Where am I going wrong.

    cheers

    http://wordpress.org/extend/plugins/custom-fields-shortcode/

  2. veeco
    Member
    Posted 5 years ago #

    I believe what you are trying to do is simply insert a custom field into a template? To do so, you just need to have the right php code in your template to grab the custom field:

    http://codex.wordpress.org/Using_Custom_Fields

    Should look like this:

    <?php $key="score"; $result= get_post_meta($post->ID, $key, true); ?>
    <p>Score: </p> <?php echo $result ?>

    This code needs to be in a template and within the if (have_posts()) ... section of code.

    The plugin you are referencing is for creating custom fields and inserting them directly into a post or page, not a template.

Topic Closed

This topic has been closed to new replies.

About this Topic