WordPress.org

Support

Support » Themes and Templates » Dynamic link to blog from a static page

Dynamic link to blog from a static page

  • joshpuffpuff
    Member

    @joshpuffpuff

    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

Viewing 9 replies - 1 through 9 (of 9 total)
  • masterwin
    Member

    @masterwin

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

    it will point to your home page of wordpress

    Thanks
    masterwin

    joshpuffpuff
    Member

    @joshpuffpuff

    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

    pixel-Jay
    Member

    @pixel-jay

    @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?

    lockettpots
    Member

    @lockettpots

    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

    joshpuffpuff
    Member

    @joshpuffpuff

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

    joshpuffpuff
    Member

    @joshpuffpuff

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

    Thank you

    pixel-Jay
    Member

    @pixel-jay

    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.

    joshpuffpuff
    Member

    @joshpuffpuff

    @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

    pixel-Jay
    Member

    @pixel-jay

    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.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Dynamic link to blog from a static page’ is closed to new replies.