• Resolved Mary Linville

    (@sunshine)


    I searched but didn’t find an applicable question + answer.

    As I understand it, I can make use of the classes WP_Query and WP_Rewrite to modify and add to the built-in permalinks, via a plugin (I’d like to do this the “proper” way rather than hack files or modify core variables directly). Is that correct?

    If so, there are two things I’d like to do, and I’d really appreciate assistance. I’m an intermediate user of PHP, a beginner with specifically classes, and can create basic WordPress plugins, but the plugin hooks and these classes are completely foreign to me.

    1. Change my date urls from %year%/%monthnum%/%day% to %year%-%monthnum%-%day% (dashes instead of slashes)
    2. I’m going to be using /log/%postname% as the permalink structure.

    I’d like to have my comments appear on a separate page, i.e: /log/%postname%/discussion and /%pagename%/discussion.

    Can someone please show me or point to some kind of tutorial(s) on how to do this?

    (Edit: using this forum is a bit strange. There’s no preview, and I accidentally hit enter and now can’t assign any tags to this thread. Sorry…)

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Mary Linville

    (@sunshine)

    Okay did something change between 2.0 and 2.0.1? I had the basics working, and now (on 2.0.1) it doesn’t work. It’s so frustrating because I had it working just fine before. Maybe it was just a fluke, I don’t know. The important thing is, as far as I can tell it should be working, but it isn’t.

    I want to have this: /%category%/%postname%/discussion (enable comments on their own page). If I were making the rewrite rule by hand, I’d have (.+?)/([^/]+)/discussion/?$ point to index.php?category_name=$matches[1]&name=$matches[2]&discussion=1.

    Adding to the query string (so I can do the template magic) isn’t the problem, the problem is that the rules are not getting added at all. I know they aren’t because I not only get a 404 error, nothing even remotely like my rule shows up in the rules array returned by a call to the class’ rewrite_rules method.

    I’ve now tried all the variations I could find – and yes, my plugin is activated. ??

    I’ve tried doing it the Feed Director way, the jaseone way, the ChristineD way, the mcnicks way, in various combinations with the generate_rewrite_rules, rewrite_rules_array, and post_rules_array filter hooks.

    Please help.

    As long as you hadn’t changed or deleted your .htaccess file during the upgrade, and had the specific permalinks as before (incase)..then, just re-applied the permalink structure as before.

    Updated the .htaccess file…you should be fine. I had no problems with mine through the upgrade process. Even the addons to the .htaccess file for certain plugins..was ok for the most part.. just had to do a minor tweak..except for that..I was fine. ( For a GamerZ Print Plugin)

    And that was even going off “saved” files and such after all my directories and such being hacked..

    spencerp

    Basically saying, all my inner core files of my WP were hacked and gutted, and I had to reupload all backed up files of it..and was ok..

    All in wp-admin folder
    Almost all in the wp-includes folder
    Almost the whole wp-content folder

    All three blogs and gallery was gone basically.. This is what I had seen when I got online, minus my added comments to his page on the ScreenShot lol!

    https://www.vindictivebastard.net/images2/hacked.gif

    And to think, I was the last one hacked on the 6th, and the little prick bastard hacked 14 others or more on the 7th…flucking god damn it!! LOL!

    Sorry about my last post maybe…maybe I just mis understood and I don’t want to mislead you..I’m not sure. :/ I was basically going off your last reply, because I thought that was the latest “updated” response of it all..

    spencerp

    Hello!

    I made my permalink structure /%category%/%postname%/ and I expected to see links like this https://www.mobitek.bzi/phones/post-slug, but I see this https://www.mobitek.biz/category/phones/post-slug. What do I have to do to remove this word ‘category’ from links?


    Amien

    Just use this then:

    /%postname%/

    or

    /%postname%.htm/

    spencerp

    It’s not good solution. For 2 posts in different categories but with the same postname. For example news/post1 and phones/post1 I’ll get one link post1.

    No, WordPress ensures that there aren’t two posts with the same slug (which I wish was an advanced option as I’ll never have two permalinks that are the same).

    Thanks Viper =) Overlooked this earlier.. =(

    spencerp

    Thread Starter Mary Linville

    (@sunshine)

    Uh, thanks for the response spencerp, but the regular, built-in permalinks are not what I’m talking about. I’m talking about extending them, customization not available via the admin interface, with the WP_Rewrite ands WP_Query classes, using plugin filter hooks. For example, the new WordPress “tag” plugins extend them beyond what you can do in the admin interface.

    Amien, that’s strange that exact permalink works great for me. Where are these incorrect permalinks getting output? You could try additionally customizing the category permalinks, perhaps that will help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Extend/customize permalinks with wp_query and wp_rewrite’ is closed to new replies.