Forums

How to have friendly navigation links (5 posts)

  1. aodhan
    Member
    Posted 1 year ago #

    I've created a new Theme with a template for the home page and a template for the rest of the site (including the bloge bage).
    Lets say I've 3 pages Home, Blog and Contact Details. Using the console I've set the "Front page displays static" and pointed that at the home page and set the blog to point at the blog page.

    I want to creat a link from the home page to the blog page.

    Now what I can do is something like this :
    <?php wp_list_pages('include=5&title_li=<h2>' . __('Pages') . '</h2>' ); ?> where 5 is the id of the "blog page"

    Or

    <?php bloginfo('template_url'); ?>/?page_id=5'

    However if this changes in the console then i'll need to change the code.

    Is there a way to generate a link that always points to the blog page?

    Or is there a way to generate the link based on the pagename? I've been playing with the get_option('home') but get_option('blog') doesn't seem to work for me.

    Thanks in advance

  2. MichaelH
    moderator
    Posted 1 year ago #

    One possibility is the Redirectify plugin

  3. aodhan
    Member
    Posted 1 year ago #

    Thanks for the suggestoin MichaelH but I don't think that will do exactly what I'm looking for. Let me rephrase the question slightly:

    Is it posible to set up links based on the already know page name?

    So if I have a page that I know to be called "blog" but I don't know the page_id is there a way to call it?

    Something like:
    <?php bloginfo('template_url'); ?>/?page_id=5'
    But instead of page_id I would like to have page_name or page_title or something like that.....

    Thanks again

  4. mfields
    Member
    Posted 1 year ago #

    if you are using permalinks, the following should work:

    <?php bloginfo('url'); ?>/blog/

    Just be sure that you blog page has the proper slug set.

  5. sewmyheadon
    Member
    Posted 1 year ago #

    Not sure this is what you're looking for, but I constantly use:

    <a href="<?php echo get_permalink(165); ?>">Page Name</a>

    Where the '165' is the ID of the page. This way, if you completely change the permalink structure, the links will still work.

Topic Closed

This topic has been closed to new replies.

About this Topic