• Hi,

    I’ve installed WP at the root of my domain, in an attempt to use it as a CMS.

    My blog will actually be located at /blog, but I installed it at the root because I want to show some recent posts on my root index.php

    1. So basically I created a category “blog” in my WordPress install, and all posts are posted here so they appear at mysite.com/blog

    2. I then changed permalink structure to:

    /%category%/%postname%/

    So all posts appear at mysite.com/blog/post-name/

    3. But there is a problem, on the blog homepage (mysite.com/blog) (which is actually category.php) I get a 404 error when clicking the “older entries” button.

    However if doing this at (mysite.com/category/blog) it works.

    But I just want mysite.com/blog not mysite.com/category/blog!!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Okay.

    You should move your blog to /blog instead.

    1) Move WordPress to it’s own directory – http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
    2) Get rid of the blog category.
    3) Have a beer (or soda, whatever)

    Thread Starter xdesi

    (@xdesi)

    Hi, Ipstenu,

    I wanted WordPress installed at the root because then I could have WP loops on my root homepage say, and i’d have some WP pages like about-us which would not be in the /blog/

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    You do know that if you put your blog in a subfolder, you can still have it act as if it’s in root? Read the link. You’ll see. It works. You can even further customize with a static front page, so the layout of that page is totally different than the blog.

    As for why you’re getting url.com/category/blog …. your category should never be the ‘main’ page for your blog.

    1) Move WordPress to it’s own directory – http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
    2) Change your permalinks to blog/%postname%
    3) Get rid of the category ‘blog’, you won’t need it.
    4) Customize your front page – http://codex.wordpress.org/Creating_a_Static_Front_Page

    Thread Starter xdesi

    (@xdesi)

    Hm, I’ve managed to sort the problem, pagination now works for mysite.com/blog..the fix, courtesy of themadhat.com:

    1) In wp-includes/category-template.php search for the following line of code:

    $catlink = get_option('home') . user_trailingslashit($catlink, 'category');

    Just below that, insert the following:

    $catlink = str_replace('/category', "", $catlink);

    2) In wp-includes/classes.php search for the following block of code:

    if ( isset($error) )
    $this->query_vars['error'] = $error;

    Just below that, insert the following:

    if (@$this->query_vars["name"] == "page")
    {
    $tmp_ar = $this->query_vars;
    $this->query_vars = array();
    $this->query_vars["paged"] = str_replace("/", "", $tmp_ar["page"]);
    $this->query_vars["category_name"] = $tmp_ar["category_name"];
    }

    Source: themadhat.com

    Any idea why this fixes it, I don’t like editing core files, because the problem is just going to come up again when I update WP?

    EDIT: I am reading through your most recent reply now!

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Yeah, editing core is always a bad idea 🙂

    IMO, it’s better to ‘start over’ and get the layout in a normal way working, and then customize the links. You should be able to do all this pretty simply.

    Just don’t move your blog to the ‘blog’ folder (do ‘wordpress’ or something).

    Thread Starter xdesi

    (@xdesi)

    My bad I moved the core files to a folder called blog first but i’ve changed it now to a folder called wordpress. Would it matter at all what this folder was called, it’s not used for anything is it, apart from the wp-admin login link?

    Also I just re-named the category blog to something random, it wouldn’t let me delete it because there has to be 1 category it seems. The cat name doesn’t matter anyhow since it’s not being used right?

    Right, I just have 1 problem, I’ve already got my own index.php in my themes folder which has it’s own stuff going on, to act as my homepage (mysite.com), this works.

    But now how do I get my recent posts to show up at mysite.com/blog, what would the file be called (i’ve got the code i already had it in my category.php, just need to know how to show it at mysite.com/blog)?

    mysite.com/blog currently shows a 404!

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Would it matter at all what this folder was called, it’s not used for anything is it, apart from the wp-admin login link?

    It could conflict if you have a virtual and physical folder named the same. Links might go weird.

    mysite.com/blog currently shows a 404!

    This probably means you didn’t update the blog right when you moved it.

    Add these two lines to the wp-config.php file in blog, immediately after the initial <?php line.

    update_option('siteurl','http://example.com/blog');
    update_option('home','http://example.com/blog');

    Use your own URL instead of example.com, obviously.

    Thread Starter xdesi

    (@xdesi)

    Thanks I managed to sort it using
    http://codex.wordpress.org/Creating_a_Static_Front_Page

    Thanks a lot for understanding my problem, as I know my explanations were pretty poor, but I guess I can finally move onto point 3 of your first-post and have that beer 🙂

    As a side-note you don’t know if I can just remove categories altogether do you?
    I try to post without selecting any cat selected but it just selects one for me automatically when I post..

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    You have to have at least one category for WP, IIRC. Probably a holdover from the old days when we didn’t use tags.

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

The topic ‘WP Permalinks Problem’ is closed to new replies.