0

So I have my admin bar hidden by default, because it's ugly, instead of writing a bunch of if statements so certain elements to the WP-admin panel only appear for logged in users, so far so good.

The one I'm having trouble with is the 'all posts' screen, the url is wp-admin/edit.php, yet that gives me a 404 error.

This works, takes the user to the new post screen.

<?php 
            global $user_login;
            get_currentuserinfo(); 
            if ($user_login) :
            ?>
            <div class="sectionblocktwo">
                <div class="writeurl">

                    <a href="/wp-admin/post-new.php">Write</a>

                </div> <!-- end div loginurl -->

            </div><!-- end div sectionblocktwo -->

        <?php endif; ?>

This does not work. This only fails to work when on the single.php, since it's an looking for the url sitename.com/single-post-name/wp-admin/edit.php, the other links work fine on single pages.

              <?php 
        global $user_login;
        get_currentuserinfo(); 
        if ($user_login) :
    ?>
        <div class="sectionblocktwo">
            <div class="loginurl">

                <a href="wp-admin/edit.php">My Posts</a>

            </div> <!-- end div loginurl -->

        </div><!-- end div sectionblocktwo -->

<?php endif; ?>

Is there some php code or something I can use to link to the all posts part of the dashboard?

1 Answer 1

0

Your 2nd example omits the leading / in the URL -- does /wp-admin/edit.php work?

Also, you're wiser to use admin_url(), since it's possible to change the Admin URL to something other than /wp-admin. Instead of <a href="/wp-admin/edit.php">, use <a href="<?php echo( admin_url( 'edit.php' ) ); ?>">. It's more complicated, but much safer.

1
  • Perfect, didn't know about admin url, thank you.
    – andy
    Jun 20, 2013 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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