Support » Fixing WordPress » Get post parent from searchform.php

  • Resolved Coraux



    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,

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘Get post parent from searchform.php’ is closed to new replies.