I'm facing a very common problem with Wordpress, I don't see the list of my templates in the post edit page. There are tons of posts about this here but I haven't found the solution to my problem in any of them.
I basically have this in my theme directory: index.php, page.php, header.php, functions.php, sidebar.php, style.css
in page.php and index.php, I have:
/*
Template Name: HOME
*/
and
/*
Template Name: PAGE
*/
What I've already tried:
- switched back to the original Wordpress theme and back to mine
- made sure permission 755 was attributed to folder
- copied a working file from another theme and inserted my code into it
- completely logged out and came back
but nothing worked, I still don't see the list of templates for my theme while for official themes, I do see the list of page templates.
Any suggestions?
Thanks
Laurent
You cannot use index.php or page.php as a Page Template, because those files are reserved for other templates of a theme.
As the Page Template reference states:
Name your template file so you can easily identify its Template Name, e.g., filename my-custom-page.php for template name "My Custom Page". Some coders group their templates with a filename prefix, such as page_my-custom-page.php (Don't use page- prefix as WordPress will interpret the file as a specialized page template.)
For information on Theme file-naming conventions and filenames you cannot use, see reserved Theme filenames.
Related
I am developing my WooCommerce theme (hereinafter referred to as WC).
WC does not see the single-product.php template, and load index.php instead. At the same time, on the catalog page, the custom archive-products.php is loaded.
Guys, neither custom nor original single-product.php is loaded. Tell me, please, what to do?
I did:
Create woocommerce directory in theme folder
Inside mytheme/woocommerce I placed custom archive-products.php and single-product.php
I added WC support in functions.php. I checked the support in the site admin panel - everything is ok.
Check the directory again and make sure the file name is correct. it must be archive-product.php Not archive-products.php.
It's better if you copy the plugin template file in your theme directory then modify it.
Example: To override the archive-product.php, copy: wp-content/plugins/woocommerce/templates/archive-product.php to wp-content/themes/yourtheme/woocommerce/archive-product.php
Reference: https://woocommerce.com/document/template-structure/#how-to-edit-files
I have a Wordpress website, now i want to change the post template name how it displays in the Wordpress CMS. Now it's saying "Standard template", i want to rename this to "News", just for usability reasons.
I can't find a way to do this. I know you can create new post templates by creating new files, but it always takes the single.php as standard template. I'm also using a child-theme, so i dont want to delete the single.php file, just rename the text: "Standard template".
Thanks in advance.
I tried creating a new post template file with a custom title. This doesnt solve problem, as the single.php file will still be the standard one (i dont want the user to have to change the template).
You can use another single.php for another post type for example if you have news registered as a post type you could have a single-news.php and that file then would server all the single views of postype = news. But from what i understand you would like to create a template appearing to the user with a different name. For that the best practice is to create a directory inside your child theme and name it page-teplates. Inside this directory you can create as many different templates you want and wordpress will recognize them but adding the following code at the top of each template. For the sake of the example lets say i want to create a contact page template. I will create a contact.php file inside the directory page-templates and have these lines of code inside.
<?php
/**
* Template Name: Contact
**/
get_header();
/* My templates Code/Design Here */
get_footer();
The possibilities are endless.
The code in this post will generate a dropdown box similar to the one that you see in pages.
All it requires is a little editing of your child themes functions.php file .
In most cases, you just need to copy your single.php file to a new file name in your child theme and edit the functions.php file in your child theme. Name your templates as seen in the code Dimitrios posted.
consider using the premium elementor page builder to create custom post templates that you can apply at will.
Try a plugin like Post Custom Templates Lite
I've just created a website using wordpress and a custom theme for it. This is my theme directory
/themes/customtheme/
-index.php
-header.php
-footer.php
-blog.php
....
The index.php includes header,footer,information to shown on my website, and a link to my blog page.
Blog file will looks same as normal blog site.
May i know how to write a hyperlink(a href) in index.php under theme directory so that it can prompt to the blog.php when click?
If I understand well your question you need to create a new page template using your blog.php file. Just add the following code at the beginning of the file:
<?php
/*
Template Name: My Blog Page
*/
And then create in the backed a new page and associate it to the newly created template.
Read more about page templates here.
How do I include a php page in a wordpress post?
I know how to include in pages, using /* Template Name: templatename */ and select a value from dropdown attributes. I don't know how to achieve this in a post, can you help?
i have file ex.php and i want to display the contents of the file in post article.
The template file for single posts is single.php
Depending on your theme you might have to create it
(for example copy index.php and name it accordingly)
see http://codex.wordpress.org/Theme_Development#Single_Post_.28single.php.29
Wordpress themes have standard file such as header.php, footer.php, index.php, functions.php, style.css, ...
How to add a php file to wordpress theme addition of standard files? for example I want add a news.php to display specific posts in it, please help me
Just add a new file (e.g. news.php), and put the template comment at the very beginning:
<?php
/*
Template Name: News Template
*/
Then, go to your Wordpress backend, create a new page, and select the template you created: