Search code examples
phpwordpresspermalinks

wrong permalink generated by wordpress in php program


I am developing a wordpress application to maintain animal shelter info. I installed wordpress in a sub-directory with the plugin "PHP Everywhere".

I created 2 wordpress pages. "our-pets" (the first page) simply includes the path to the main php program. In the program, an option can be selected that will document.form1.submit() the action "animals-detail" (the second page).

But wordpress generates/displays the wrong permalink: WRONG: mysite.com/subdirectory/our-pets/animals-detail RIGHT: mysite.com/subdirectory/animals-detail

What am I doing wrong?


Solution

  • I think in your form's action attribute, you've set the value as animals-detail without a slash before it. Which will get the current path and add the action's value to it.

    You could,

    1. add action='/animals-detail'
    2. Use WP's permalink function. E.g. if ID of the animals-detail page is 59 use this action="<?php the_permalink(59); ?>"