[Resolved] Get post parent from searchform.php
Here’s the context: template-page.php calls sidebar.php that calls searchform.php.
I have a script at the beginning of each page that gets the ID of the post parent and grand-parent of the post. The script works fine in template-page.php as well as in sidebar.php. The problem is that I can’t get it from searchform.php.
I need this in searchform.php to be able to change the color of the text according to the section (parent) in which I am.
I think the problem is that in searchform.php, wordpress thinks there is no post, and there is none obviously but there is one in the page that calls the sidebar that calls the searchform, you see.
By the way I use
$post->post_parentto get the post parent ID.
Any idea on how to achieve this ?
Thanks in advance,
- The topic ‘[Resolved] Get post parent from searchform.php’ is closed to new replies.