I developped a theme for Wordpress for one of my client and in that order, I created multiple pages in html for the moment. Except my index (static homepage) using the "single" template I think, I have other pages (each one is different and using different style CSS).
Is it possible, and how should I create and name the custom PHP pages in order to get each page displayed by its own html basis and styling?
Didn't find any matching answer on the internet yet, just general stuff about pages in wordpress, not custom ones.
Thank you a lot by advance if you can help me!
Separate php file for each webpage
Name each php file what ever you like, it does not matter
Add a template name at the very top of each php file
/*
Template Name: Unique Name
The template is for ....
*/
Open the wordpress backend with wp-admin and press create new webpage. When creating the new page select the template name you want.
Done !
It is hard to completely understand the problem. I notice you have .html theme and you want to use this template as page template. In this case you have to create a file in the root of theme with name: cutome1-page.php and this file needs to start with the following line:
<?php /* Template Name: Custome1 Page */ ?>
after that, while you create page in wordpress panel, you see a template as : Custome1 Page
Related
I'm creating a custom wordpress template. Usually i create files with the page name, for example if a have a page about, I create a file page-about.php and works fine. And I add acf fields to pages.
But if i want to create a new page with same structure of about pages without create a new php file? How can i do that?
Thank you.
In your question you stated you usually created your custom pages based on the page title, I would recommend you create a custom page template that can be applied to as many pages as needed. You would need to create a .php file along the lines of custom-layout-about.php and put a php comment at the top to let wordpress know it's available.
<?php /* Template Name: custom page layout -- about */ ?>
Then apply your acf fields to target the page template.
It has been a few years since I properly worked with WordPress. Now I have a proposal to build a WordPress site where every page has a custom design and only some areas of each page is editable.
The reason for this is to build a bespoke layout on each page which cannot be messed up by someone non-technical editing it in the CMS, except for small areas which they can customise.
e.g. A page contains one div which has some text in it, which can be edited in the WP admin backend, but the rest of the page cannot be edited.
Can this be done? How?
Edit: There needs to be multiple editable areas not just one. I know how to make custom pages/templates.
One method may be to create new page templates. Just create a new file in your main theme folder (or the templates folder if there is one). As long at the top of that file contains the line:
/*
Template Name: <your template name>
*/
You can design the page however you want. The data pulled from the admin section will go wherever you invoke
the_content();
The rest of the page can be hardcoded.
Then on the post edit page, on the right side (usually), you can choose the template with your template name for that page. It may be a good idea to copy the current post.php or single.php into your custom file and work from there.
For restricting access you can look at setting up user levels and keep your content contributors as "Authors" instead of "admins" so they can't change themes or edit settings.
(See https://codex.wordpress.org/User_Levels)
For creating specific unique pages with an area that gets changed you should look into custom Page Templates. You can create a page template by dropping a php file with the right naming structure into your theme hierarchy and it will get picked up by the back-end as template option when you create a page.
(See https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/)
I solved this problem using a plugin called Advanced Custom Fields which does exactly what I required.
I don't want to edit the template files - I'd like to make a new template file. I'm looking in the MySQL registry, but all I see is a table for posts, not pages. Someone mentioned the editor earlier, but that doesn't help with creating new templates.
I think I create a php file in my content>theme>my_theme directory, but I'm not certain.
Thanks for any help.
This should help you out:
It shows you which pages map to which template, and how new templates should be created. As an example, if you created an About Us page (singular, static page with the default page template), here's what Wordpress checks for:
Is there a file called page-about-us.php?
No? Is there a page called page-#.php (where # is the pageid)
No? Just render the generic page.php
In your case, if you want to edit a single page (it's a page right, not post?) .. then simply creating a file called page-$slug.php would be sufficient .. WP will use that "template" when rendering that page.
If it's still a bit unclear, check out the source link here (it makes things crystal clear!): http://make.wordpress.org/docs/theme-developer-handbook/part-one-theme-basics/template-hierarchy/
You can create your own template files in your theme directory, or a subfolder. Use a comment on top that has the name of the template.
/*
Template Name: Custom Template
*/
You can assign the template to a page under the "Page Attributes" box in the dashboard.
Of course you need more than just that comment to display anything in your template. You might stay by copying the content of your theme's index.php, then edit from there.
[NEW AT WORDPRESS]
I'm creating my own wordpress theme with own css etc etc. I've managed to get everything good in the index.php file, and I'm trying to make the other pages as well now.
When I make the home.php, blog.php, about.php and contact.php file (in my theme folder) they don't link to it. I'm following the "WordPress 3: Creating and Editing Custom Themes with Chris Coyier" on Lynda.com and the example shows that whenever you make a file with the same name as your page, it takes that directly (which works at his tutorial).
Anyone that could know what is going on?
Example:
I got a file blog.php in my theme folder, and when I go to www.mydomain.com/blog the loaded file is the index.php file, instead of the blog.php file
There are two ways you can get this working using custom page templates.
Create a template for one specific page using the page slug or ID. In this case, change the name of the php files like this to match the name of the page you created in the UI: page-home.php, page-blog.php, page-about.php and page-contact.php
Much more flexible is to create a custom template that can be used on ANY page. Just add the template name to the top of the php file like so (inside the php block):
/*
Template Name: My Home Page Template
*/
Then edit the pages and select your custom template from the template dropdown menu (on the right hand side I think, if its visible).
Reference this page for more info: https://developer.wordpress.org/themes/template-files-section/page-template-files/
Found the solution to my (silly) problem.
Creating a page in your theme directory & adding the template comment at the top of your php file isn't enough. You need to go to the admin panel->pages->YOUR PAGE-> and check out the page attributes. There you can link the page to a certain template: http://d.pr/i/a0m0
If my title wasn't clear, basically what I'm trying to do is to add my own HTML or PHP page to Wordpress, so i can play around with some web dev.
So essentially I just want a test page/pages added to my site. However since I have installed Wordpress on my website, I can't just add "index.html" to my root folder using my FTP client. I wonder if I can/can't do this and if so how to link to the pages I add using FTP.
Sorry if this doesn't make any sense. I just want to add some of the sites I've already made / ones I am creating to my site so I can easily show clients/employers what I can do, and I apologize again if I'm being an idiot.
Create a sub-directory in your root folder and then simply link to it:
www.domain.com/mysubdir/index.php
the other way to do this... create a page template in wordpress
create a php file named: template_mypage.php
You must put this php comment line at the top of your template file:
/* Template Name: My Page */
go to wordpress backend and create a new page
in the "Page Attributes", you can find a drop down list named "Template". In the list, you should be able to find "My Page"... select it and then save your page.
view it!
You can always create a subdomain or create a folder inside public_html/www/ and redirect it from any other domain or from any static link you have on wordpress
Why not use WordPress and put your portfolio together using Custom Post Types? I recently presented on this and there is a handy plugin for Custom Post Types UI that you can create a whole new section of your site and make templates for your portfolio.
Just a thought.
If you do a static page in WordPress, you can still template using the Page system as specified in another comment. Code your page, separate it into header, footer, content, etc files. You can load the file to your root, but not name it index. If you do a subfolder, you need to not have an existing page in WordPress.
HOWEVER, you can still do a "halfway" static page still using WordPress and do a header-staticpage.php, index-staticpage.php, and footer-staticpage.php and make sure to include the code for WordPress header and footer in the new header and footer so you can still reap the benefits of the default jquery that WordPress allows. Don't forget to name your template and when you create the page in WordPress, you can just leave the content area blank if you have hardcoded the page's content in.
I still recommend trying Custom Post Types. It is not hard and there are some great presentations in Slideshare that cover this aside from the plugin I mentioned earlier in this comment.