• Resolved Cory.Nickerson

    (@corynickerson)


    Again forgive my newbiness. I’m working on my first plugin and I am having difficulty setting up a custom pages to be displayed, I understand how to create them for the admin area but not for the public area of the site.

    What hook do I have to use in my plugin file so visitors can access my custom pages the plugin is creating?

    Thanks again.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    Access to WP pages is the same regardless of how they were created. The path to each page is it’s slug. You either need to add your own links to them somewhere, such as a menu pick, a manually created ‘contents’ page, or create another page which queries for the pages and displays some aspect of them (permalink, excerpt, etc.) in ‘the loop’.

    Thread Starter Cory.Nickerson

    (@corynickerson)

    The pages aren’t through the WP blog system or whatever their system is. It’s a custom coded .php file. I don’t know how to create that for wordpress. How do I make a custom file that integrates into wordpress and find its url or whatever?

    Moderator bcworkz

    (@bcworkz)

    OK, I think I understand now. “Page” is an unfortunate ambiguous term in WP. I took your meaning to be the post type “Page”. I now believe you are referring to a directly requested PHP page. If that part is straight now, I’m still not sure what you’re trying to do with it. As long as you aren’t trying to call WP functions, a php page should work as it would without WP. If you do need access to WP functions, require_once() the wp-load.php file. If the page requires the user to be logged in, require_once() wp-admin/admin.php instead.

    If you want your page to have all the front end styling, you’re probably better off converting it to a page template (the post type “page”) and creating a corresponding page (post), which is then referenced through it’s assigned title slug instead of the file name. Making a page template is mostly a matter of inserting a properly formatted comment at the top and storing it in the theme folder. Then when you make a page (post), you don’t need to do any more than assign a title, unless the template specifically wants content from the DB, in which case you would enter that as well.

    I hope this all makes some sort of sense. Too many kinds of pages! Sheesh!

    Thread Starter Cory.Nickerson

    (@corynickerson)

    Well what I have is a 5 page series of forms. It’s a 10 question form using radio buttons the user submits. The form submits to itself and validates the information to make sure there is no empty fields, and if there are no errors it passes them along to the next page in the form. I need it to match the style for the rest of the site, with the header and footer and whatnot.

    Moderator bcworkz

    (@bcworkz)

    Wow, you and r_honey are on almost the exact same track! ??

    I’ll just re-post the same response in case you haven’t seen it yet, it’s a little out of context but directly applies to your situation as well.
    ——–

    You are free to develop your own stand alone pages, just require_once() the wp-load.php file (wp-admin/admin.php if login required) in order to have access to WP functions. You would then need to create the styling yourself, which would have been one of the advantages of the template. You may be able to simply include the theme header template to get a good part of this done, I haven’t included header files in my own work, so not sure of any side effects.

    The other advantage of the template approach lost is the permalink system, but you can implement this if desired with the Rewrite API.

    So such an approach is attainable, just a bit more work.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hook for creating a custom page?’ is closed to new replies.