WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Page template to link to other pages (2 posts)

  1. davestewart
    Member
    Posted 6 years ago #

    I've seen the topic of linking to "static" pages come up a few times, but this is slightly different.

    My WP enabled site is here: http://www.keyframesandcode.com

    On the top right, I have 3 links, and the bottom one "Latest developments..." links to the archive of "Development".

    Basically, it's a standard page template, and the content is just a javascript that changes the browser's location.href to the permalink of my "Development" category.

    http://www.keyframesandcode.com/code/category/development/

    To me, this screams "HHAAACCCKKKKKK!!!!!!", and I feel dirty. Plus, there's an annoying pause as it loads the first, then the second page.

    Is there a better way to do this?

    I have one idea:

    1. I enter the url I want to redirect to as the page content, in this case 'http://www.keyframesandcode.com/code/category/development/'.
    2. Then in the page template, I just grab that value and then output it as part of a PHP location header:
      <?php
      $link = the_content();
      if($link){
      	header("Location: $link");
      }
      ?>

    I think it all sounds very logical, but am I doing my usual thing and over-engineering here because I don't know wordpress well-enough?

    Cheers,
    Dave

  2. davestewart
    Member
    Posted 6 years ago #

    Well I just went ahead and did it, and it couldn't be easier.

    • I just stick a URL in the Page Content area
    • Set the template as Page Redirect
    • Publish

    Niiiiiiiiiiiiiiiiice.

    More info and download is here.

Topic Closed

This topic has been closed to new replies.

About this Topic