Environment
Docker wordpress container, AWS Linux based vm server
Issue
These permalinks end up going to pages I have no use for. I want to change the location these tags direct to. I found a wordpress filter that gives me direct access to the original permalink as they get outputted to the buffer, Heres the filter in action
At the top of my functions.php at the root of my theme I set a hash table linking tags to new locations
Now time to debug. I want to make sure that the filter is capturing exactly what I would like it to. Below you see a condition involving a regex pattern that if matched changes the right permalink
Debugging
I wrote a post titled “Simple debugging in wordpress” giving direction on how to easily setup a system to debug in a more effective manner. Instead of killing the script over and over again line after line, which works in a lot of cases, I recommend an alternative. Heres the post. Since i’m working from a docker container, I have terminal access, but in the mentioned post I have methods of debugging under strict limitations.
Command sequence
I need to find the id my wordpress docker container goes by
docker ps
Then i want to step into the container and start up a bash shell
docker exec -it ithaca_coding_wordpress_1 /bin/bash
In my case, the root directory was /var/www/html, If not for you just change directory
cd /var/www/html
Create a file where you plan to output to
touch werm.log
Give the file full permissions
chmod 777 werm.log
Use Tail to print contents of werm.log in realtime
tail -f werm.log
Again, heres the function that I want to debug.
This line writes all terms (tags) being outputted on the site to my log file
Here you can see Tail working its magic
Now I return the new location using a key pulled from the matches generated by the regex pattern.