How to put own HTML into Wordpress theme? - php

I installed a Wordpress theme, but I would need to put there my own HTML code.
So, I would suppose I'll go into: wp-content/themes/theme_name/header.php and on the needed place I inserted needed HTML code.
I did it, but it didn't affect the website - the newly put HTML elements are not seen in the website.
Do I disregard anything? Or is needed to set up something in the WP administration?
Or problem with cache?
Sorry, maybe a stupid queston, I am just playing with WP for the first time.

The pages of your blog are created from different theme "parts". header.php is one of them. it creates the header of the page. Usually, before most HTML is output. footer.php is used for the footer of the page.
If you want your HTML code to go in the homepage only, use index.php (which calls header.php and footer.php). If you want your code to show in a page, use page.php. If you want your code to show when viewing a post, use single.php. Hope this helps.

Look in your different pages if get_header() function is called correctly. It is this function that includes header.php.

Check also your "theme_name/inc" directory. Sometimes the header.php or footer.php can be placed in the main theme folder and in the inc. If that is the situation you need to make sure to be editing the right file (the one in /inc).

First you have to check in wp-admin which theme is actives in your site suppose there are three theme and twenty eleven is active and you were checking twenty twelve so maybe this reason your new html will not shown in front-end so please check your current theme and work according to that from this location you can check it your current theme go to wp-admin => appearance => themes

Related

Link custom header in Wordpress

I am trying to achieve the basic function of using a custom header on my home page in Wordpress.
I am only just learning wordpress but I will try and explain.
So I have both a parent and child theme, the parent theme has a folder called 'inc' with a file custom-header.php ready to tailor.
I have duplicated the 'inc' folder and placed it in my child theme folder.
At the top of page.php file in the parent folder (there is no duplicate in the child folder) I have changed
get_header(); ?>
to
get_header(custom-header); ?>
I have tried making dramatic changes in both the Parent custom-header.php and the duplicate child custom-header.php and nothing happens.
I have also tried changing the file names, for example header-home.php and then calling
get_header("home"); ?>
and this does not work either.
I have put the get_header in the top of the page.php as I think this is where it is served from (with my limited knowledge) and when I try and edit it, the page fails to reload, so I would assume it is the right php file but I am obviously doing something wrong. I have spent quite some time looking but it is suprisingly difficult to get a clear, concise explanation on the right syntax and exactly where I place the get_header code and actually keep the custom header file.
Any help would be great.
The only correct versions you used was:
//file: header-home.php
get_header('home');
Unfortunately for header files, they need to be in the root directory of your active theme (or parent theme if using a child) to be called. i.e. themes/custom-theme/header-home.php
You are correct as in you change the get_header() function in your page files, but dont forget your home page may be front-page.php, home.php, index.php or a page-whatever.php if using a wp page as the front page.

How do I edit an individual page in WordPress

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.

Wordpress - all pages link to the index.php file

[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

How to integrate HTML pages into WordPress?

I have a page in HTML(index.html), and a folders named images, css, js that used in it.
Now i have to do this in WordPress. Is there any plug in to convert Html to WordPress or any other way to do this in WordPress? Please help me.. i'm a beginner in WordPress.
I am not sure of a direct way to implement a HTML page into a WordPress theme, but if you have made header and footer files for your website, then all you need to do is convert them to make them WordPress compatible.
You should refer to the codex.
You can also go for any of the WordPress frameworks listed here.
A WordPress theme is easy to understand if you know basic PHP. It has a set of files like
header.php // header file
footer.php // footer file
index.php // the index file
page.php // for your WP pages
single.php // for your WP posts
and some other files
Go through the codex and it shouldn't take long to get the hang of it.
You need http://themematcher.com/
It'll automatically take your site, styles, images etc and create a wordpress theme for you. Check it out
Search for HTML to WordPress theme conversion and you can find so many good tutorials.
Check this article:
http://thethemefoundry.com/blog/html-wordpress/
Theres really only three ways:
Hire a freelancer
Convert manually by referring to http://codex.wordpress.org/
Use an automated converter. Best one on the market is
https://htmltowordpress.io
here is the link for complete solution of this problem.
http://wordpress.org/support/topic/how-to-integrate-htmlphp-page-to-wordpres?replies=6
make sure to add
/*
Template Name: Custom Page Template
*/
piece of code in index.php page at top in your selected theme folder, not on ur main index.php file.

wordpress use in own template

I've created an HTML page as part of my website which I would like to use as a template for news articles. The page has all the things it needs, it just needs to display the correct news article in it.
I installed WordPress on my webserver and now wonder how I can have wordpress publish articles using my HTML page?
Is this even possible since WordPress works with php?
thanks
What you are talking about is themes. Wordpress allows you to create a theme for your installation so it displays using your html/css (more or less)
The way I do this is copy the default theme and make changes in there, and then you can switch to your new theme in your settings.
Edit: in addition, you can also load up wordpress on any page using:
include( '/path_to/wordpress_install/wp-load.php' );
This will allow you to use wordpress functionality on any page of your site.
just edited the single.php file by pasting the desired html code and leaving the loop code there where the text needed to show up.
didn't need to break up the page in a header, body and footer. Left out sidebar for now, but will put it back after I edit it properly.

Categories