wordpress use in own template - php

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.

Related

Wordpress - creating custom pages with php code

I need to add few additional pages to my wordpress site.
These pages should not be "part of the site", ie they should not be linked somewhere from the posts and so on.
However, they should have the same header/footer as the rest of the site ( I am using custom theme ). And they should be accessible via url.
The final requirement is, I should be able to code in php.
At the moment, I tried to create a new "Page" in my admin console. And then write some php-code inside. However, all my php code gets commented and since not executed.
I don't think that installing plugins such as Exec-PHP is a good idea, so I am trying to find other solutions.
Any comments/advice/suggestions how to make it?
I would be grateful if you give me some how-to link.
Thank you in advance.
You can use a custom page template in your theme for this and just keep the site empty in the admin panel:
http://codex.wordpress.org/Theme_Development#Custom_Page_Templates
By using Template tag's you can create custom page.
write this code on the top of your php file....
/*
Template Name: Your Template Name
*/

Wordpress plugin using existing theme

I am building a plugin for the first time and I have setup my rewrite rules to call a PHP file I have located in my plugin folder and this is working but all I have it output just now is "test"
I wanted to ask, is there is a way of pulling in the existing theme and using this as the basis for the page, then I can have my plugin just output the page content area so to speak.
My plugin is quite big in terms of the amount of data it handles so I would like to be able to use a menu link to the aforementioned file and this file can then output all the sub pages of content but still using the default theme (theme I have made) and fill the content area only is this possible and if so is there anything to explain this already available because I couldn't see it.
Any help with this would be much appreciated.
Edit: I have tried including a file from my current theme but this will give me a 500 error so I assume its not as simple as this.
Have you thought about using custom post types for your plugin content rather than relying on custom tables and separate code?
Other than that, you could use a shortcode (just one) and have users insert that into a regular WP page, the shortcode then displays all of your various plugin stuff.
It's hard to be more specific without understanding why you've done it this way.

Make special pages from WordPress theme?

I'm trying to figure out how a certain WordPress sets things up. I'd like to have a special page where I could make WP calls and interact with the theme, without affecting anything else.
I just making test.php and putting it into my theme's folder, but that doesn't work.
#Eliran provides one possible option, but you could also add a page in the back-end of WP, just make sure it has the slug 'test', and change your 'test.php' filename to 'page-test.php'. If you're worried about the public seeing this, set the page visibility in the admin to 'private'.
Edit:
to move your understanding along a little further also, you should review the way that WordPress determines what file to grab to render a particular URL. This can be pretty confusing to start with, so be patient if you're not familiar with it, but it's at the heart of designing WP themes. I'll link to the examples, and if you scroll down a little there's a diagram that, along with the text, will help you see how WP is 'thinking'.
http://codex.wordpress.org/Template_Hierarchy#Examples
You can see here: Page Templates
all you need to do is create a page named page-{custom-name}.php and add it to the theme folder.
and inside this php file add:
/*
Template Name: My Custom Page
*/
and than to use this page you need to go to the wp-admin, add/edit a page and chose it:
inside the php file everything you do is classic wordpress.
all this is giving you is a custom page tamplate.
Put it in your root folder. When you go to look at it, you'd look at www.mywebsite.com/test.php
It may be other ways to do this, but I rather use the rewrite API and custom query vars, to create custom routes.
A previous answer on the subject can be found here
The basic idea is to add a new url rule, catch the query var with the parse_request filter and maybe do a die or redirect to prevent the default wordpress template from loading.
I prefer this over theme templates, because with templates you need to create a page for each new url, and if that page gets acidentally deleted, that functionality would stop working.
What Pages are Not:
Pages are not Posts, nor are they excerpted from larger works of fiction. They do not cycle through your blog's main page. WordPress Plugins are available to change the defaults if necessary.
Pages cannot be associated with Categories and cannot be assigned Tags. The organizational structure for Pages comes only from their hierarchical interrelationships, and not from Tags or Categories.
Pages are not files. They are stored in your database just like Posts are.
Although you can put Template Tags and PHP code into a Page Template file, you cannot put these into the Page or Post content without a WordPress Plugin like Exec-PHP which Read overwrites the code filtering process.
Pages are not included in your site's feed.
Pages and Posts may attract attention in different ways from humans or search engines.
Pages (or a specific post) can be set as a static front page if desired with a separate Page set for the latest blog posts, typically named "blog."
More About Pages.
In WordPress to add a new page you have to log in to the admin/backend and from the pages menu you can add a new page. In this case, you can select templaes for your page and also you can create a custom page template for that page.
You may read Createing a new page in WordPress. and custom Page template in WordPress.

Adding my own static webpage to a wordpress site

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.

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.

Categories