Title: Creating a URL
Last modified: August 19, 2016

---

# Creating a URL

 *  [Sevenhelmets](https://wordpress.org/support/users/sevenhelmets/)
 * (@sevenhelmets)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/creating-a-url/)
 * Hi folks
 * I need some help here. I am trying to create something, and I have no idea how
   to achieve it.
 * I originally built my site on a different platform, and when I installed WordPress,
   decided to put it on a subdirectory “domain.com/blog/”.
 * I’ve recently rebuilt it, this time based completely on WordPress. I’m using 
   wp-ecommerce as the main part of the site, and want to keep the blog where it
   is.
 * However, as wp-ecommerce also uses “posts” as product listing, obviously the 
   blog has to be installed at the base directory. The only way I could separate
   things is by creating a separate category, specifically for the blog. So now,
   the blog can only be linked to from a custom menu which links to the “blog posts”
   category.
 * This results in the URI:
 * domain.com/category/blog
 * however I want it to look like the original (in order to retain page rank, if
   nothing else), so it should point to
 * domain.com/blog
 * How can I do this? I thought it would be a 301 redirect, however I don’t believe
   that is correct. Any ideas would be MUCH MUCH appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/creating-a-url/#post-1802763)
 * Try a different approach.
 * 1) Create a WordPress PAGE (not post) called Blog. That will give you a permalink
   URL of domain.com/blog
 * 2) Now you need to tell WordPress to display posts from the category blog on 
   the page called blog.
 * Open your theme’s file page.php in an editor. If you don’t have an editor you
   can use the WP online editor in the Appearance section of the Dashboard menu.
   Location of the page.php file:
    `/wp-content/themes/{themename}/page.php`
 * find the start of the WordPress loop:
    ( loop looks something like this- sometimes
   on one line)
 *     ```
       <?php if (have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
       ```
   
 * add this code before the lines above
 *     ```
       <?php
       if (is_page('blog')) {
         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
         query_posts("category_name=blog&paged=$paged");
       } ?>
       ```
   
 * Save the page.php file.
 * What is happening here: you’ve created a page with the url of
    domain.com/blog
   On that page you are displaying all the posts from the blog category. This creates
   what you are looking for. If the first post has a permalink of `lost-my-cat` 
   its URL will now be `domain.com/blog/lost-my-cat`
 *  Thread Starter [Sevenhelmets](https://wordpress.org/support/users/sevenhelmets/)
 * (@sevenhelmets)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/creating-a-url/#post-1802927)
 * You are a STAR! Thank you, that worked pretty well. Just a few slight issues –
   it’s only showing the last 3 posts (with no links to “read previous ones”), and
   they are all “expanded”. The theme previously was showing snippets only, and 
   would take the first image from the blog post and display it as a thumbnail using
   Tim Thumb, which I’m totally unfamiliar with.
 * Any idea how I could achieve that? I’m so grateful for your help, because doing
   the programming side of things is definitely something I couldn’t have done.
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/creating-a-url/#post-1802928)
 * well, you could make a copy of index.php, and call it something else…say blog.
   php
 *     ```
       <?php
       /*
       Template Name: Blog
       */
       ?>
       ```
   
 * put that at the very top
 * and then do the same edit you did to page.php above.
 * Then, in the page editor for your blog page, assign the blog template to it from
   the dropdown in the right column. That will cause it to use the copy of index.
   php we just made, which will display the posts the same way they used to be displayed
 *  Thread Starter [Sevenhelmets](https://wordpress.org/support/users/sevenhelmets/)
 * (@sevenhelmets)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/creating-a-url/#post-1802929)
 * Thanks for the response Rev. Voodoo!
 * Unfortunately I can’t _quite _follow the last part of your instructions. Are 
   you referring to editing the page in the page editor section (Appearance —> Editor)?
 * I followed your instructions so far – copied index.php, renamed it blog.php, 
   inserted the
 *     ```
       <?php
       /*
       Template Name: Blog
       */
       ?>
       ```
   
 * At the very top of the file, and then inserted
 *     ```
       <?php
       if (is_page('blog')) {
         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
         query_posts("category_name=blog&paged=$paged");
       } ?>
       ```
   
 * Just before the “if have posts” part of the code.
 * But after that I’m lost – is the blog.php suppose to be the new index page? Any
   help would be much much much appreciated, unfortunately I don’t have a single
   shred of programming experience, so I’m just picking up as I go…

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Creating a URL’ is closed to new replies.

## Tags

 * [redirect](https://wordpress.org/support/topic-tag/redirect/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [Sevenhelmets](https://wordpress.org/support/users/sevenhelmets/)
 * Last activity: [15 years, 7 months ago](https://wordpress.org/support/topic/creating-a-url/#post-1802929)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
