I have code which updates the database fine, but the page doesn't update correctly! I have to refresh the page a second time for it to update correctly.

Here is the code below (funcitons/admin-website-options). The most important line is the <input type="radio" .... line:

add_action('admin_menu', 'add_website_menu');

function add_website_menu()
        add_menu_page( 'website Options', 'website Options', 'administrator', 'website_options', 'echo_website_menu');

function echo_website_menu()
        if(isset($_POST['submit-change-front-story']) )
                $new_post_id = intval($_POST['front']);
                global $post;
                $args = array('tag' => 'front-page');
                $posts = get_posts($args);
                function get_ids($post) {
                        return $post->ID;
                $posts = array_map("get_ids", $posts);
                wp_add_post_tags($new_post_id, 'front-page');
        <div class="wrap">
            <h2>Manage Stories</h2>
            <form action="<?php echo $_SERVER['REQUIEST_URI']?>" method="POST" class="story-admin-form">

                <h3>Front Page Stories</h3>
                <?php query_posts('cat=5'); // all posts with category of "story" ?>
                <div class="posts">
                        <?php while ( have_posts() ) :
                                global $post;
                                $post = array();
                                the_post(); ?>
                                <input type="radio" name="front" value="<? echo the_id(); ?>" <? echo has_tag('front-page', get_the_id()) ? "checked":"" ?>/> <? echo the_title(); ?><br/>
                        <?php endwhile;?>
                        <input name="submit-change-front-story" type="submit" id="submit-front-page-story" value="Change Front Page Story" />

Every time I change the front-page story, both of the select options are "checked", but I can view the posts in the admin view and only one of them has the 'front-page' story. (???) And when I refresh the page, then the options have only one selected.

Does anyone know what's happening?

1 Answer 1


Maybe instead of using a tag, you could use get_post_meta() to retrieve a custom field? Set a meta field like featured and test to see if it's set to one or something.

$featured = get_post_meta($post->ID, 'featured', true);
if ($featured === 'yes') echo 'selected';

I hope I understood your question the right way and that this helps you out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.