• How do I display an already existing WordPress page in PHP? I google’d for ages and read loads of documents online. It felt like being in a snowstorm.

    If I know the page ID can I just display a page?

    I want to be able to display a page that contains search results from a query. So this PHP file will be the one pointed to by ‘action’ in the <form>. I then just need to display the WordPress page that contains the shortcode which deals with the form being posted.

    The shortcode function will display the search results. That bit is easy. I just don’t know how to display a page in WordPress.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Can you provide more context of what you want to do?

    I think this is a good start point for you – https://codex.www.ads-software.com/Creating_a_Search_Page

    Cheers,
    Ramesh

    Thread Starter speedy_snail

    (@speedy_snail)

    Thanks for your wise response Ramesh. I should have been more clear.

    I don’t want to search my website, but rather a set of rented properties. I want the user to be able to search by number of bedrooms and min / max monthly rent etc. I am not happy with the plugins available as they cost a lot or aren’t sufficient for what I need.

    Am I right in thinking that the link you sent is only intended for searching a website (i.e. it’s pages and posts etc), rather than other content inside a database. In my case I will have a rented property database (of flats / houses etc). One plugin I saw seems to add each property as a custom page, but I’m not convinced this is the best way. I want to have a separate database for the property data.

    I really hope you respond as I’m really stuck right now. Your help is really appreciated.

    Thanks
    Mike ??

    jack randall

    (@theotherlebowski)

    use tags to assign things to different posts/properties.

    things like 4 bedrooms, all inclusive etc and then set the cloud search widget on the home page (or wherever you want) and when someone clicks 4 bedrooms all of the properties that have that tag assigned to it will be listed.

    there are other ways of doing it; create categories like 4 bedroom etc and then people can search that category to see all 4 bed houses.

    the most complex solution is to create your own custom post type to handle the content in exactly the way you want. ??

    Thread Starter speedy_snail

    (@speedy_snail)

    I’ve found a much easier solution.

    The search page has a shortcode that displays the search form (<form> etc). The action attribute in the form points to another page (the search results page). The search results page has another shortcode which calls a function to display the search results.

    This means I have complete control over both pages. Job done!

    Thanks for your support. I feel I didn’t explain myself well enough. I do like the cloud search widget idea though. That is a fantastic way to display properties, especially if the visual of the text cloud could be improved to be more snazzy.

    Have a great day and huge thanks for your patience.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to display a WordPress page in PHP?’ is closed to new replies.