Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom WordPress page (using a plugin)

I want to create a custom page that has tournament brackets instead of the usual content. I have read some of the WordPress documentation and found how plugins work and how I add admin pages to administer the page.

What is needed to create the page itself (and have it listed on the site)? Do I need to create a custom template that has the majority of the work in it? Do I need to have the plugin create the page or where do I start?

Also, how do template pages and plugins interoperate? Does WordPress provide me a reference variable to the plugin or do I have to load it "manually"?


I think I'll reformulate my question. While the answers have been helpful, they aren't exactly what I've been looking for.

Basically, I want a page where I have some module / code / whatever that controls whatever goes on there. This means I can't just set up a page since then I can only fill in text. I need a page where I can decide what happens when I go to that page, what is written, submits, etc. I am fairly fluent in PHP, just not WordPress :)

The second part is the admin, where I need a page (or several) to control some of the administration stuff of said page.

like image 692
Christian P. Avatar asked Aug 17 '10 15:08

Christian P.


People also ask

How do I create a custom page in WordPress?

Go to WordPress Admin Panel > Pages > Add New. You can see the new custom page template listed on the right side. Create a new page and set its template to PageWithoutSidebar. Once done, Publish it.

How do I make a programmatically page in WordPress?

Firstly we need to check if the post we are going to create is available or not. If present you dont need to create another one you can edit the content of the page. But if you changed the title of the page new page will be created. Here I have created a page with the help of title of the page.


1 Answers

So far answers I've seen are overtly complex. What you should do is simply this:

  1. In WordPress, create a new page; title it "example" - note the slug it generates. It should be "example" as well, mimicking the title.

  2. Create a file in your active theme called page-example.php - mirroring that slug.

  3. Sandwich your custom PHP with bare-bones HTML code in page-example.php:

     <?php get_header(); ?>
    
     <!-- Your custom PHP code goes here -->
    
     <?php get_footer(); ?>
    

Depending on your page, you may need to recreate a few div elements, and possibly toss in a get_sidebar().

like image 119
pp19dd Avatar answered Sep 30 '22 17:09

pp19dd