WordPress.org

Support

Support » How-To and Troubleshooting » Please help – Need a text hook

Please help – Need a text hook

  • I’m lost trying to add a fairly straightforward php if/else into my page. I’ve got as far as creating the statement and inserting it into the correct place in page.php, but I can’t figure out how to ‘call’ it properly. All I want is that if a particular word appears, the function is called and prints its result in the page. Can anyone tell me how I can structure the command to do that please? I’ve been at this for HOURS!!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi

    @esmi

    Forum Moderator

    Where exactly will this word be? In the page content as generated by the_content() function?

    Yes, its in the_content. Basically I’m trying to check for a shipping option being present within a Woocommerce cart page, and if so to print a warning. In an ideal world I’d modify the output of the call that posts the shipping element there in the first place, but woocommerce seems to be almost *intentionally* complicated to unpick!

    esmi

    @esmi

    Forum Moderator

    I don’t know the plugin at all (I help to maintain one of its competitors) but I’d imagine that the plugin is actually adding this content via the_content() filter. so if you try to parse the content before their function is added to the filter, you’ll never find your keyword. Have you tried dumping the whole $post object, meta field details and any session info to the screen? You might find what you’re looking for in there.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Please help – Need a text hook’ is closed to new replies.
Skip to toolbar