Unable to integrate downloaded HTML template in wordpress Theme - php

I am trying to Convert my HTML template into Wordpress template.But on browser it is only showing content without CSS. I refered the procedure from: https://www.elegantthemes.com/blog/tips-tricks/converting-html-sites-to-wordpress-sites
here I added a below given statement on the top of a CSS file.I am confused about what to write in Theme URI and Author URI, as Right now I am workin on localhost server.
/*
Theme Name: ThemeIntegration
Theme URI: ??
Description: A brief description.
Version: 1.0
Author: You
Author URI: ??
*/
I am only getting Simple html content without styling.

You need to add css and js files either in header or functions.php file, that tutorial is incomplete you can refer this link
If you have only 1 css then you can directly write it in style.css

Related

How to add(include) elementor created page in theme file 404.php

I created a page using elementor(named as: 'Error-page'), currently using linoor theme. What I want is to load this 'Error-page' via theme's default 404.php file (NOT using any plugin). Should I just type in 'include Error-page.php' in 404.php file to make it work?
Meta: My goal is to show my custom error page which I created using elementor(named as: Error-page) when invalid url is typed. One way of doing it is using plugin(I prefer not to do this for the time being), 2nd way could be somehow including this custom page in theme's default 404.php file
Note: Im new to wordpress
after thinking about your question, i have 2 solutions for you:
1. if you do not have code knowledge
This way is simple and safer, but have limits than other way - it's not using your template but redirect viewer to your template page. Any way, the same result
Build the 404 template with Elementor and publish it
Open your theme's 404.php file
In the very first top of the template file **(below <?php tag) paste this code:
wp_redirect( '/your-template-slug' );
exit;
Save it and you're done
2. If you have basic code knowledge:
This way is a litle complex, but it alow you to using not for 404 file - but other templates (archive, categories...)
Install "Anywhere Elementor" plugin
Build the 404 template as you do with Elementor
Get your template php shortcode
Edit the theme's 404.php file to echo out your template
In case you need more detail guide, i have record a step by step guide video here

Wordpress using wrong template

I have installed Wordpress multisite (5.5.1) and created some custom post types. I have also created some custom templates.
Custom post type: "illustration"
Template file: illustration.php
The template file is empty apart from the name and an echo showing the template name
Theme Name: ae-2020
Template Name: illustration
Template Post Type: illustration
*
The template for displaying illustration pages
*
Version: 1.0
Description:
*/
The template name shows up in the page attributes dropdown. However when I view the post the index template is used. If I go to posts and view the "Hello World" post it uses my single.php template as expected.
What am I doing wrong?
Help appreciated.
David
Maybe this can be helpful, this shows what prefixes and names to uses in wordpress hierarchy of templates
And here a link with wordpress documention of theme development https://codex.wordpress.org/Theme_Development
This template is use for illustration post type. That mean it's just apply for illustration post type. While the "Hello world" is wp builtin post type and it's use single.php as template in default!
if you want to display the post using your template, change template's header into this:
Template Post Type: illustration, post

How to convert a Shortcode into a Plugin

1. Shortcode (working)
I have made a Shortcode which display the current weatherinformations from yahoo. There was 3 Files (simple-pie.inc, simple-pie-yahoo.inc and yahooweather.php) and I grabed the content of these files and pasted it inside my function.php – works good!
This looks so and got more then 16.000 Lines of Code:
// Add Shortcode for weather
function get_rohrau_wetter() {
content of simple-pie.inc
content of simple-pie-yahoo.inc
content of yahooweather.php -> return "weather-html"
}
add_shortcode( 'rohrauwetter', 'get_rohrau_wetter' );
2. Plugin (no clue where to start)
All I want to do is making a Plugin out of my working shortcode to get that "wall-of-code" out of my function.php and of course for better reuseability. Also I think so it will be possible to turn the simple-pie cache to "on" for faster processing…
My Question is: How do I convert my Shortcode into an Plugin?
A good place to start would the plugin handbook: https://developer.wordpress.org/plugins/the-basics/header-requirements/
But the cheap and nasty way to place it into a plugin, create a directory for your plugin, create a index.php (realistically it can be any name) file. Add this in
<?php
/*
Plugin Name: WordPress.org Plugin
Plugin URI: https://developer.wordpress.org/plugins/the-basics/
Description: Basic WordPress Plugin Header Comment
Version: 20160911
Author: WordPress.org
Author URI: https://developer.wordpress.org/
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wporg
Domain Path: /languages
*/
Then underneath it add in your above functions. Obviously Change out the text to suit yourself so that you can identify the plugin. Then upload it too your plugins directory.
As I said, this is the cheap and nasty way to set it up. I would advise to have a look at the plugin handbook I linked to above. Also Using OOP plugin development is advised, a good starting point is Tom McFarlin tutorial on tutsplus: https://code.tutsplus.com/series/object-oriented-programming-in-wordpress--cms-699 .. and after that well worth looking at https://github.com/DevinVinson/WordPress-Plugin-Boilerplate and https://wppb.me/ hope that all helps.

Include wordpress theme in a custom php page

I need to include a custom PHP page in Wordpress.
So what I need to do is just to show this custom php page using the Wordpress theme installed on that Wordpress.
Does not mind which theme is up, the custom php page will have to be shown under any theme is installed in that moment.
How do I do it in Wordpress?
I am new to Wordpress development.
Thanks
Creating a custom php page that will be able to be viewed in any theme (and have the theme applied) would be considerably difficult.
Each wordpress page calls specific theme functions of that particular theme, as well as referencing files of that theme to generate header, footer, css files, javascript files, etc.. Your custom page would need to plan for all of these contingencies, for each possible theme used.
Here's a alternative solution: inject PHP code directly into a standard wordpress page via this plugin http://wordpress.org/extend/plugins/allow-php-in-posts-and-pages/
Meaning: you make a normal wordpress page, but are able to add php to it. When this page is rendered, the proper page template is used, and all the theme references are taken care of for you.
You could do this easily with a page template. WordPress allows you to create page templates which can be assigned to a page via the 'Page Attributes' panel within the page editor. These templates are php files inside your theme directory which begin with some code like (see this page in The Codex for more info):
<?php
/*
Template name: Custom PHP Page
*/
?>
<?php // begin custom PHP page ?>
Typically a template is a variation on the regular theme files (such as page.php) and would call the get_header() and get_footer() functions and have an instance of the loop. However if you simply want to use a custom PHP page, then all you need to do is create the file you want inside the current theme directory and add the above code at the very top of the file.
To output the custom PHP page on your site, you would need to add a new page via the admin area and then assign your new page template to this page.
Alternatively, if you want to include a custom PHP page inside an existing theme file, you use the code:
<?php include(TEMPLATEPATH . '/includes/file.php'); ?>
in this case your custom PHP file would be located inside a directory called 'includes' within your current theme directory.
Tim.
It's not that difficult. Here's what you need:
Once you include the main wordpress blog header, the entire armamentarium of wordpress functions is available to you, which allows you to get the active theme's directory. Once you get that, just include the header and the footer of the theme.
// If title is not displayed before loading the header, Wordpress displays "Page not found" as the title
echo "<head>
<title>Your page title</title>
</head>";
// Include the Main Wordpress blog header
include $_SERVER['DOCUMENT_ROOT']."/wp-blog-header.php";
//Now, you need to get the active theme's folder, and get a relative path to that folder
$homeurl=home_url();
$ddir= get_bloginfo( 'template_directory');
$current_theme_relative_path=substr_replace($ddir, "", 0, strlen($homeurl));
//echo "<br/>The relative path to the currently active theme is ".$current_theme_relative_path;
//Once you have the path, include the header and footer, adding your custom php code in between.
// Include the specific theme header you need
include $_SERVER['DOCUMENT_ROOT'].$current_theme_relative_path."/header.php";
// Your custom PHP code STARTS here
// Add anything you want to display to the user
echo "
<h2>
Your form has been submitted
</h2>";
// END of custom code
?>
<?php
}
// Now end with the theme's footer
include $_SERVER['DOCUMENT_ROOT'].$current_theme_relative_path."/footer.php";
?>
Was very helpfull (even if dated of 2011-13)
Also, as a thank you, i'm sharing the version i made
it's usefull if your wordpress folder is not located at ROOT
PasBin Link - wordpress custom php page
just change the value of $wplocalpath in :
// Wordpress path (if wordpress is not located at ROOT
// $wplocalpath="/Wordpress1";

How Does Wordpress Read Comment Title?

I'm working on my own little back end framework for future clients and I'm making a folder named "Forms" to store all of my forms for CMS interaction. Inside the forms folder I'd like to store .php files similar to wordpress style plugins that I can title in the comments code like wp does... ie
/*
Plugin Name: Name Of The Plugin
Description: A brief description of the Plugin.
Version: The Plugin's Version Number, e.g.: 1.0
Author: Name Of The Plugin Author
Author URI: http://URI_Of_The_Plugin_Author
*/
I'm wondering how WP reads that data as it is commented out... do they use file_get_contents('plugin.php'); and parse it as well as include the plugin? Is there a php function to actually read comments?
Thoughts?
Read the file by FTP or file_Get_contents()`
explode each line by : and get result in array
array[0] makes the key and array[1] makes the value.
Wordpress has created its own function to handle file headers. I used this in my new Total Widget Control Plugin. Here's the function name and help docs on how to use it.
get_file_data( $file_path, $headers, $context)
http://codex.wordpress.org/File_Header
string $file: Path to the file
array $default_headers: List of headers, in the format array('HeaderKey' => 'Header Name')
string $context: If specified adds filter hook "extra_{$context}_headers"

Categories