WordPress.org

Ready to get started?Download WordPress

Forums

problem (4 posts)

  1. bikeman123
    Member
    Posted 1 year ago #

    I am using
    <a href="<?php bloginfo(‘home_url’); ?>/newpage/">newpage</a>
    in my theme

    Something is wrong. Instead of linking to
    http://www.domian.com/newpage/

    it is linking to
    http://www.domain.com/currentpage/sitetitle/newpage/

    How can this happen?

    Sorry the site is not live so I cant provide a link.

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    If you don't want the home URL, why not take it away?
    This

    <a href="/newpage/">newpage</a>

    Should return http://www.domian.com/newpage/

    By the way, you have weird apostrophes that could cause problems in the future.

  3. bikeman123
    Member
    Posted 1 year ago #

    Hi

    Thanks for your reply but what you suggest doesn't work because the 'newpage' link will be relative to the current page and many of my pages are sub-pages of parents. So a link to newpage within http://www.domain/sub-page/ would end up at http://www.domain/subpage/newpage.

    I need to use the siteurl to give me absolute links.

  4. alchymyth
    Forum Moderator
    Posted 1 year ago #

    review

    http://codex.wordpress.org/Function_Reference/bloginfo

    or

    http://codex.wordpress.org/Function_Reference/home_url

    possibly (untested):

    <a href="<?php echo home_url('/newpage/'); ?>">newpage</a>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.