• So, I want to add a custom field to my functions.php.

    I have this so far but its not showing calling up the tag. What am I doing wrong.

    functions.php page

    <tr valign="top">
    			<th scope="row"><label for="racing">Next Race Status</label></th>
    			<td>
    				<input name="race_status" type="text" id="flickr_group_id" value="<?php echo htmlspecialchars(stripslashes(get_option('race_status'))); ?>" class="regular-text" />
    			</td>
    		</tr>

    sidebar.php page

    <div class="box ads race_status">
                                    <div class="content">
                                            Next Race Status:<?php echo get_settings('race_status'); ?>
                                    </div>
                            </div>
                            <!--/race status -->

    Thanks for the help,
    Adam

Viewing 6 replies - 1 through 6 (of 6 total)
  • get_option?

    If this is a custom field, shouldn’t you be using get_post_meta?

    Thread Starter caligrafx

    (@caligrafx)

    I am not sure that is why I am asking. How would I write the codes. I tried replacing get_option with get_post_meta and the function page went crazy?

    Adam

    The problem here is that we’re only seeing half of the picture. How are you entering these custom fields? I’m assuming that each Race is a post and that you are entering a value under a custom field for each Post/Race, yes?

    What’s the name of the custom field?

    Thread Starter caligrafx

    (@caligrafx)

    Ok let see if this helps any!

    I have the wordpress theme called “Convergence” that I got from themeforest!

    Inside of the “Convergence Theme Settings” I saw that they have a couple of fields to enter some text and want to add another by just copying and pasting the php above the already existing script. Inside of the functions.php page I added this;

    <tr valign="top">
    			<th scope="row"><label for="racing">Next Race Status</label></th>
    			<td>
    				<input name="race_status" type="text" id="flickr_group_id" value="<?php echo htmlspecialchars(stripslashes(get_option('race_status'))); ?>" class="regular-text" />
    			</td>
    		</tr>

    Then I wanted it to be on the top of the right side bar and saw a couple of things and tried somethings and got this but never got it to work :(.

    <div class="box ads race_status">
                                    <div class="content">
                                            Next Race Status:<?php echo get_settings('race_status'); ?>
                                    </div>
                            </div>
                            <!--/race status -->

    What it is for is for me to enter a couple of words to say that the local dirt track is still scheduled to race or if it is canceled.

    Right now the div box is there and has the words “Next Race Status:” but there is nothing display for the custom field I tried making.

    In the back in the cause text field is there but when I try to text something in it, it just goes back to “<br /> <b>Warning</b>: Missing argument 2 for get_post_meta() in <b>/homepages/1/d174344245/htdocs/diecastcollectibles/wp-includes/post.php</b> on line <b>666</b><br /> when ever I hit the save button.

    Sorry if I am not making any sense on this but I have no idea what I am really talking about with the php part of the theme.

    Thanks for your time,
    Adam

    Here is a live link to my site I am trying to put it on!
    Live Link Here!

    I don’t know the Convergence theme but I’m pretty sure that you can’t use the code from a theme options page to create a custom post meta field. Have a read of Using_Custom_Fields and see if you can build your custom fields from scratch. I think it will be a lot easier in the long run.

    Thread Starter caligrafx

    (@caligrafx)

    Ok I have now created a custom field in my about page called “race_status” and have “normal schedule” in the value.

    In the sidebar.php file I have added;
    Next Race Status:<?php get_post_custom($race_status); ?>

    what am I doing wrong now?

    Thanks again for the help,
    Adam

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Show text on template’ is closed to new replies.