How to load custom php file in Wordpress themes - wordpress

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.

Related

In Wordpress website, connecting to another web_based application

I want to create a page in word press website, that shows information from external DB by API. What should I do?
But other pages and theme are in the Wordpress database.
Thanks in Advance
Set up a custom template. It can contain all the custom code you need, such as the API to call the external database. You create a new template by copying and modifying the page.php file from your theme. Just remove the parts you don't want and at the top put your new template name in a comment line like this:
/* Template Name: External-DB-Page */
Save that to a file such as external_db.php, upload it to your theme or child theme directory and then in your functions.php you include the file by adding
require_once 'external_db.php';
This new template called "External-DB-Page" will now be a selection available when choosing a page template for any page in WordPress.

How to make the page in developed from Scratch using Html, CSS and JS my homepage in Wordpress

I want to use the page I design from scratch using HTML, CSS and JavaScript as the default homepage to WordPress.
The page is not on WordPress. I created it myself.
Make it a template file by adding this line to the first line
<?php /* Template Name: Homepage Template */ ?>
place it in your theme folder
Go to WordPress admin and create a new page, select template option to be Homepage Template, save it.
Now go to WordPress settings, Reading and select it as homepage.
Hope it helps

Wordpress template list not showing up in posts

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.

Wordpress: create a custom home page

I want to create a website using wordpress, but I want my website to have a customized home page, created by me, completely different from the theme of the site, and then link the wordpress pages directly from my page.
Is this possible? How can I achieve this?
Can I simply create the page, and link the other created with the wordpress panel, without breaking everything?
According to official WordPress codex:
If a visitor goes to your home page at http://example.com/blog/, the following happens:
WordPress first determines whether it has a static front page. If a static front page has been set, then WordPress loads that page according to the page template hierarchy.
If a static front page has not been set, then WordPress looks for a template file called home.php and uses it to generate the requested page.
If home.php is missing, WordPress looks for a file called index.php in the active theme's directory, and uses that template to generate the page.
Therefore you just need to create a home.php template and place it with the other theme (which so ever theme you will use) templates and WordPress will automatically start using home.php template for the home page.
Just copy the default page.php template file and call it front-page.php. Change the configuration at the top of that file. Now create a new page called home.
Go to Administration > Settings > Reading panel and set a static front page.
For more help check this link on the Wordpress website:
https://codex.wordpress.org/Creating_a_Static_Front_Page
If you create HTML off your home page first than this is easy for you
First Create a file Like this "template-home.php" in your theme.
Now in "template-home.php" First you must write these lines at the top of the page
<?php
/* ==========
Template Name: Home
========== */
?>
After that add your header.php and footer.php like this:
<?php get_header(); ?>
// Your Content is here
<?php get_footer(); ?>
Now your Whole HTML is work between in Header and Footer
Then Go to your Admin Panel
Go to Pages > add new
and create a page named "Home"
NOTE: When you create a page Please Select a Template of Home and "Publish" it.
Then go to Settings > Reading and select "A static page (select below)" radio button, then a drop down is active and select your "Home" Page Then click on save changes.
I hope this will help you
You can create a front-page.php file in your active theme folder.
It can be use for both Your latest posts or a static page as you want.

How to add a php file to wordpress theme addition of standard files?

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:

Resources