I have a few websites where I have coded a custom feature to get data from the database, these are all older sites. the page fetches info by grabbing the last part of the url and turning it into the variable 'item'


this used to work, but now it no longer does. something is stripping off the last part of the url and it's just loading example.com/item/

The workaround of changing the url to


has 'fixed' it but I'd rather the other url. Can anybody shed any light on what has happened here? I believe this happened on a wordpress update a couple of versions ago.

** edit to add some code **

this is in the theme's header.php file

I use the plugin pods to create custom tables so i'm using it's db query functions

    $itemURL = 'https://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    $bits = explode("item/",$itemURL);
    $showItem = rtrim($bits[1],"/");

    $customPod = pods('custom_jewellery');
    $params = array('where' => 'id = "'.$showItem.'"');
       $customItem['id'] = $customPod->field('id');
  • It would really help if you just included the code. It's impossible to say anything without it. Jul 1 at 16:07
  • what code should I post? Something is redirecting/rewriting the url from /item/123/ to just /item/ this is happening before the page loads, so before the theme files come into play
    – trundles
    Jul 1 at 20:12
  • “ I have coded a custom feature to get data from the database” Jul 2 at 2:10
  • So I've added some code to the post... I have a website that has identical code on 2 different pages. One works, and the other does not. so the one that works keeps the url (ie: example.com/item/123/) and the one that does not converts the url from example.com/test/123/ and changes it to example.com/test/
    – trundles
    Jul 2 at 17:25

So I never found out why this broke in the first place, but I did find a solution that forces the proper url to work

add_action( 'init', 'add_mypage_rule' );

function add_mypage_rule(){

Sussed out from here: https://stackoverflow.com/questions/18713230/wordpress-url-rewriting-parameters-in-url

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.