WordPress.org

Ready to get started?Download WordPress

Forums

Custom Fields Creator
Custom Fields Creator (2 posts)

  1. ghosterfire
    Member
    Posted 1 year ago #

    i using below code at single.php

    [ Mod note: for code, please use the code button or backticks instead of blockquote. Much easier to read that way. ]

    <?php
    	get_header();
    	include(THEME_LIB.'/template_posts.php');
    	get_footer();
    ?>
    <?php $Information = get_post_meta($post->ID, "Information", true);
    if( !empty($Information) )
    foreach($Information as $Information) {echo $Information ['Platform'];} ?>
    foreach($Information as $Information) {echo $Information ['License'];} ?>

    but the custom field still not show

    http://demo.mlch.antserve.com/?p=63

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

  2. madalin.ungureanu
    Member
    Plugin Contributor

    Posted 1 year ago #

    Hi!

    At a first glance there are a couple of mistakes in your code:

    - in the get_post_meta function the meta key should be lowercase "information"
    - same goes for the array keys when you are echoing stuff out: 'platform' and 'license'
    - the foreach statement is wrong

    <?php $Informations = get_post_meta($post->ID, "information", true);
    if( !empty($Informations) )
    foreach($Informations as $Information) {echo $Information ['platform'];}
    foreach($Informations as $Information) {echo $Information ['license'];} ?>

    Hope this helps!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.