• I would like to add a link to the write post form on the public site that will display when I am logged in so I don’t have to go to the admin site and then go to the new post form. I know, I know, its a few clicks, but it will also be easier for my wife.

    Is there a plugin out there for this or is it easy to add to the templates?

Viewing 15 replies - 1 through 15 (of 20 total)
  • Just manually add a link where you want it to appear.

    https://yoursite/wp-admin/post.php

    Thread Starter brianlees

    (@brianlees)

    Thanks. But, how do I get it to only show up when logged in?

    Oooh I missed that part. ?? Hmmm….

    Ok, here’s a thought… I don’t know how to make it a plugin, maybe somebody smarter could do that, but you could hack the function… the wp_register function shows either the register button or the site admin button depending upon if it’s a logged in registered user. So you could change the function to point to the post page instead of the dashboard.

    In wp-includes/template-functions-general.php find wp_register. Then change

    $link = $before . '<a href="' . get_settings('siteurl') . '/wp-admin/">' . __('Site Admin') . '</a>' . $after;

    To say:

    $link = $before . '<a href="' . get_settings('siteurl') . '/wp-admin/post.php">' . __('Make a New Post') . '</a>' . $after;

    I tried just adding the second line to see if it would show both, but that didn’t work. Maybe it’s just missing something to make it do that.

    Thread Starter brianlees

    (@brianlees)

    Hmm…my site is pretty clean and only has two users, so I don’t have the register displaying. I just have a login link in the footer. I appriciate the help, but I would prefer to not hack it so I don’t have to worry as much with upgrades in the future. I’m just supprised there is no tag that can wrap code to display depending on your login status. I couldn’t find anything in the CODEX after a quick glance, but I might have missed it.

    Maybe a reworking of the ‘Logged in as’ section of comments.php?

    <?php if ( $user_ID ) : ?>
    <a href="<?php echo get_option("siteurl"); ?>/wp-admin/post.php">Post new article.</a> <a href="<?php echo get_option("siteurl"); ?>/wp-login.php?action=logout" title="<?php _e("Log out of this account") ?>">Logout &raquo;</a>
    <?php endif; ?>

    Seems to work?.. I also left the ‘logout’ option, thought it might be useful.

    Good thinking, Ian, but where did you put that to make it work? I put it in my sidebar a couple places and I never got anything to show up.

    I just threw it between <li></li> tags in one of my sidebar lists. It was there when I was logged in, so I logged out and it all disapeared.

    Thread Starter brianlees

    (@brianlees)

    Hmm…I added that code to my footer and nothing showed up. So, since this there doesn’t seem to be an immediate answer, I guess there is no wordpress function or tag to wrap around code? That seems like a huge oversite, doesn’t it? I mean, I know that this is only at v1.5…but still. I MUST be missing something obvious.

    I have this code in more themes:
    <?php edit_post_link(__('Edit This')); ?>
    and it shows up only when I am logged in.

    EDIT. Oops… I misread the original post. This does not take you to the write new post admin panel. Sorry.

    Brian, why not just create a bookmark for the post page?

    Put this where you want the link to appear (though you may need to change the url for post.php):

    <?php
    global $user_login;
    get_currentuserinfo();
    if ($user_login) :
    ?>
    <a href="/wp-admin/post.php">New Post</a>
    <?php endif; ?>

    Thread Starter brianlees

    (@brianlees)

    That worked. Just needed to remove the leading “/” from the href.

    What if I want to display something when the person is not logged in? Like
    Not Registered? Register Today!

    PS: I want to do this because I want to remove Site Admin link as I am making links like Submit and Article and Edit my Profile.

    Mod of example above to provide that:

    <?php
    global $user_login;
    get_currentuserinfo();
    if ($user_login) :
    ?>
    <a href="wp-admin/post.php">New Post</a>
    <?php else : ?>
    Not registered? Register today!
    <?php wp_register('', ''); ?>
    <?php endif; ?>

    May need some HTML customizing. Info on wp_register():

    https://codex.www.ads-software.com/Template_Tags/wp_register

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Can I add a “new post” link on public site when logged in?’ is closed to new replies.