WordPress.org

Ready to get started?Download WordPress

Forums

Dynamic link to blog from a static page (10 posts)

  1. joshpuffpuff
    Member
    Posted 2 years ago #

    Hi,

    I have my site setup that I use a static page for my hompage and then http://www.example.com/news for my blog. On my home page the only way I can direct users to the blog via the navigation is to create a link like this.
    <a href="http://www.example.com/news">Blog</a>
    I would really like to use the power of WordPress to link to that page more effectively. I want the link to be something more like
    <a href="<?php echo _ _ _ _ _''">Blog</a>
    What i am missing or would like to know is what I need to put in the href to link to my blog dynamically
    Thanks

  2. masterwin
    Member
    Posted 2 years ago #

    you can use the default function <?php echo bloginfo('url');?>

    it will point to your home page of wordpress

    Thanks
    masterwin

  3. joshpuffpuff
    Member
    Posted 2 years ago #

    Hi thanks for you reply but that is taking me to a 404 page now. I assume it is because I need to fill in the 'url' part.

    What do i do to link to the /news section of my site. I tried

    <?php echo bloginfo('url/news');?> and it didnt work either

    Thanks

  4. pixel-Jay
    Member
    Posted 2 years ago #

    @joshpuffpuff, are you using a separate static page (one not generated by WordPress) in normal html and css, or are you using a static front page set in the Reading settings under the Settings menu in the admin?

  5. lockettpots
    Member
    Posted 2 years ago #

    Hi Josh

    Don't replace the 'url' bit with the actual url. bloginfo('url') returns the url of the site in a browser readable form (so you don't use echo)

    <a href="<?php bloginfo('url'); ?>/news" title="News">News</a>

    should do what you want.

    For more info on the bloginfo() function have a look at
    http://codex.wordpress.org/Function_Reference/bloginfo

    Hope this helps

    John

  6. joshpuffpuff
    Member
    Posted 2 years ago #

    @pixel-Jay Im pretty sure it is separate static page not created in wordpress. Is this bad?
    Is there a way I can check?

  7. joshpuffpuff
    Member
    Posted 2 years ago #

    @locketpots Thank you very much this has resolved this issue the way I wanted.

    Thank you

  8. pixel-Jay
    Member
    Posted 2 years ago #

    Nope, not a bad thing at all. If it was just a page you created in the WordPress admin, and set as the front page via Reading settings, then you could have added a separate blog page as the main blog page (changed in Reading settings), and then just add it to the navigation of your site via the Menu settings (with custom labels).

    But since you are using a static, html and css front page, lockettpots' solution is the best for your situation.

  9. joshpuffpuff
    Member
    Posted 2 years ago #

    @pixel-Jay i was wrong it is set up in th admin section like you first described.

    Is the solution then not the best option?

    Thanks

  10. pixel-Jay
    Member
    Posted 2 years ago #

    Well, if it's a link in your navigation menu, you can add the blog page and change the reading settings like I described, but if it's just a normal link, from anywhere in your front page, then doing what lockettpots said is best.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.