Add a quick post link to your WordPress blog

WordPress’s conditional tags are pretty freaking awesome. They came to my rescue when I wanted to add a quick “new post” link to my blog pages for when I’m logged in (which is nearly all the time). Here’s a quick block of code to help you do the same…


This content originally appeared on @mdo and was authored by Mark Otto

New post

WordPress’s conditional tags are pretty freaking awesome. They came to my rescue when I wanted to add a quick “new post” link to my blog pages for when I’m logged in (which is nearly all the time). Here’s a quick block of code to help you do the same:

<?php if (is_user_logged_in()) { ?>
  <a href="/wp-admin/post-new.php" id="newPost">+</a>
<?php } ?>

That’s all you need on the PHP side; just add it to the end of your footer.php right before the wp_footer(). To style it, here’s a quick bit of CSS:

a#newPost {
  position: fixed;
  top: 0;
  right: 40px;
  background: rgba(0,0,0,.25);
  .borderBottomRadius(3px);
  font-size: 40px;
  font-weight: bolder;
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
  padding: 5px 15px 10px;
}

And that’s it—enjoy!


This content originally appeared on @mdo and was authored by Mark Otto


Print Share Comment Cite Upload Translate Updates
APA

Mark Otto | Sciencx (2010-10-03T00:00:00+00:00) Add a quick post link to your WordPress blog. Retrieved from https://www.scien.cx/2010/10/03/add-a-quick-post-link-to-your-wordpress-blog/

MLA
" » Add a quick post link to your WordPress blog." Mark Otto | Sciencx - Sunday October 3, 2010, https://www.scien.cx/2010/10/03/add-a-quick-post-link-to-your-wordpress-blog/
HARVARD
Mark Otto | Sciencx Sunday October 3, 2010 » Add a quick post link to your WordPress blog., viewed ,<https://www.scien.cx/2010/10/03/add-a-quick-post-link-to-your-wordpress-blog/>
VANCOUVER
Mark Otto | Sciencx - » Add a quick post link to your WordPress blog. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2010/10/03/add-a-quick-post-link-to-your-wordpress-blog/
CHICAGO
" » Add a quick post link to your WordPress blog." Mark Otto | Sciencx - Accessed . https://www.scien.cx/2010/10/03/add-a-quick-post-link-to-your-wordpress-blog/
IEEE
" » Add a quick post link to your WordPress blog." Mark Otto | Sciencx [Online]. Available: https://www.scien.cx/2010/10/03/add-a-quick-post-link-to-your-wordpress-blog/. [Accessed: ]
rf:citation
» Add a quick post link to your WordPress blog | Mark Otto | Sciencx | https://www.scien.cx/2010/10/03/add-a-quick-post-link-to-your-wordpress-blog/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.