• billsey

    (@billsey)


    One of the very few limitations I have with WordPress is that when I am already logged in and viewing the front page there is no direct link to just add a new post. I’ve discovered that I have to click on an “edit this” link to get to the post editor. It would be so much simpler if there was a “Post” link on the front page that only appears if the user is logged in, similar to how the “edit this” link appears. As I am not an experienced coder, especially with PHP, how would I add this to the front page in version 1.2.2 or to 1.5 should I upgrade to that version?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Kafkaesqui

    (@kafkaesqui)

    Thread Starter billsey

    (@billsey)

    Thanks, Kafkaesqui, I wish my search would have found that as quickly as yours did (of course you wrote it, too 🙂 ). Can I put that between li tags in a ul list?

    Kafkaesqui

    (@kafkaesqui)

    Sure can:

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

    Thread Starter billsey

    (@billsey)

    I’m thinking of the “log in”/”Register” ul list, adding this as a third item that would only appear when logged in. In such a case, should I put the whole code within the li tags?

    Such as:

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

    Thread Starter billsey

    (@billsey)

    YES!

    I tried my version and, after removing the leading “/” from the “/wp-admin/post.php” link it works!

    Thank you Kafkaesqui!

    Kafkaesqui

    (@kafkaesqui)

    “Such as: …”

    It’d work that way, but you’d be left with an empty list tag when logged out. So do it as I have above, but remove the <ul> and </ul> tags.

    And you’re welcome. ;)

    Thread Starter billsey

    (@billsey)

    OK, so put the user info code between the list items within the existing ul, right? If I read it right, doing it that way would eliminate the empty li tag.

    Thread Starter billsey

    (@billsey)

    And it seems to work just fine.

    Thread Starter billsey

    (@billsey)

    Since I am a php novice I have a question:

    Would it work if I were to replace

    <li id="other"><?php _e('Other:'); ?>
    <ul>
    <li><a href="<?php echo get_settings('siteurl'); ?>/wp-login.php"><?php _e('Login'); ?></a></li>
    <li><a href="<?php echo get_settings('siteurl'); ?>/wp-register.php"><?php _e('Register'); ?></a></li>
    </ul>
    </li>

    with

    <li id="other"><?php _e('Other:'); ?>
    <ul>
    <?php
    global $user_login;
    get_currentuserinfo();
    if ($user_login) :
    ?>
    <li><a href="<?php echo get_settings('siteurl')
    ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php printf(__('Logout (%s)'), stripslashes($user_nickname)) ?></a></li>
    <li><a href="wp-admin/post.php">New Post</a></li>
    <?php else ?>
    <li><a href="<?php echo get_settings('siteurl'); ?>/wp-login.php"><?php _e('Login'); ?></a></li>
    <li><a href="<?php echo get_settings('siteurl'); ?>/wp-register.php"><?php _e('Register'); ?></a></li>
    <?php endif; ?>
    </ul>
    </li>

    in index.php?

    Kafkaesqui

    (@kafkaesqui)

    It should work fine if change your ‘else’ line to:

    <?php else : ?>

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Adding a “log-in conditional ‘Post’ link” to my blog’s front page’ is closed to new replies.