[resolved] Get post parent from searchform.php (2 posts)

  1. Coraux
    Posted 3 years ago #


    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_parent to get the post parent ID.

    Any idea on how to achieve this ?
    Thanks in advance,

  2. Coraux
    Posted 3 years ago #

    Why making puzzles when it's not necessary ?
    I will just take the code from searchform.php and put it directly where I want instead of calling that page. Then it will be able to recognize the post parent.

Topic Closed

This topic has been closed to new replies.

About this Topic