I have a website build with Codeigniter and I need to have a blog. It should be a WordPress so what I decided to do is to add "blog" in my .htaccess and install a WordPress in myweb.com/blog
It works perfect.
Now, I need to change my theme header and footer from the one that I have already in my web.
How can I do it?
I have the view at views/common/header.php, but obviously, I can not load it like this in template/header.php
<?php $this->load->view('common/header');?>
If I'm not wrong, I should add any code at header.php in my template folder. So, the question is, what should I change or add on it??
Thanks a lot!
UPDATE
I think there should be a helper I could load in codeigniter in order to call that functions on Wordpress
How can I do it?
You directly cannot call CI view in wordpress file. Inorder to make changes to wordpress header and footer you will need to modify header.php and footer.php file under wordpress theme (wp-content/themes/your_theme_folder).
Also make sure that you do not modify wordpress default theme directly as any changes to default theme would be lost during wordpress updates.
Best practice is to create child theme and then make your changes over there
https://codex.wordpress.org/Child_Themes , here the guide to create child theme.
Related
I'm trying to have a pagination on my custom Products page that is not the default one in Woocommerce.
I used Elementor to customize this page and after some research I saw that I could call a function that is already integrated in WordPress using the < paginate_links > function.
The only problem is that I have no idea where to call this function in order to have a pagination on my product page.
To be more precise, i would like to know where exactly i have to change or add my php functions, and what code should i use to get my pagination.
Normally it is in the archive.php or a version of that file name specific to your post-type. But before you go and change it, create a child theme in case you haven't done that already. In the child theme folder, you then duplicate the archive.php or similar to make it overwrite the one from the parent theme. This way you keep your version of the theme clean and updatable without losing any changes.
(For creating a child-theme you will need to create at least a style.css [with a WordPress-specific comment, you can google] and a functions.php-file that needs a bit of php-code to enqueue the child-themes scripts and styles. The code for the functions.php can also be found by a quick google search. You then just place the style.css and the functions.php into a new folder you name in the pattern [foldername of your themes name]-child. You then place this folder next to the parent-themes folder in the "/wp-content/themes/"-directory.)
And here you go for the pagination: https://codex.wordpress.org/Pagination
I am creating a Wordpress custom theme, and I've been having issues with my woocommerce template rendering. Firstly, not all of the pages are showing up (some of them are reverting to the index.php and page.php files). Secondly, for the pages that are showing up (the single product page, the archive products page), the css is not being applied. I have tried everything suggested on the docs (hooks), but I have failed. Here is a link to my github for you to see the file structure.
https://github.com/naderae/elbe-collections
possible issues wuth my code:
my code is not written in the standard wordpress way. I only have three pages so far, index.php, page-about.php, and page-team.php, which work fine. page.php and single.php are empty. thus, my site consists of 2 pages, and index.php.
I've been struggling with this for 2 days, and would really appreciate some guidance of hoe to get me back on track. Cheers
Below is a list of some basic theme templates must preset in theme, more about this in details click here.
index.php
style.css
header.php
single.php
page.php
category.php
archive.php
404.php
I would recommend you to start with some default WordPress theme like twentyseventeen theme or other. These themes will have all basic functionality of WordPress. Check functions.php in the theme folder to customize/add functionality.
for more details about Template Hierarchy click here
Customize WooCommerce
Template structure & Overriding templates via a theme - link
Customizing WooCommerce - link
To overwrite woocommerce css you need to add a woocommerce folder to your theme. And go from there.
Woocommerce will also always use their own templates so the easiest way to change the layout is to use a child-plugin from woocommerce.
Im using tyche theme for e-commerce.i have created template files for pages.like profile creating page.
Template file:
<?php
/*
Template Name: Create Profile
*/
when i assign this template for a wordpress page.Its working fine. but two or three days later that template files are missing from my theme folder. What i have to do Now. Please help me.
Thanks...
This is because when theme get updated all custom codes created by user, which resides in template folder, get replaced. So it is better to create a child theme and use it.
If you modify a theme directly and it is updated, then your
modifications may be lost. By using a child theme you will ensure that
your modifications are preserved
More here
I am just asking about custom page template:
If I put it in the subfolder it will work or it should be placed in the root directory.
For example, I created a template named custom-page-awesome.php and placed it in nytemplate directory.
Please let me know that it's automatically detected when I edit some page or need to include using custom code.
WordPress recognizes the subfolder '/page-templates/'. Therefore, it’s a good idea to store your global page templates in this folder to help keep them organized.: https://developer.wordpress.org/themes/template-files-section/page-template-files/
I believe WordPress does not recognize template files that are not in the root directory of the theme. That is unless you use the following function get_template_part( 'your-template-file' );
more about that here: https://developer.wordpress.org/reference/functions/get_template_part/
You need to put this commented line on top of your template php file in the root of the theme folder. It will display the template in the dropdown menu of pages in wordpress backoffice :
is there any way to include a custom template from a folder inside my plugin page into the Wordpress system so that when I, for example create a new page/post, it can show as one of the template choices other than default of course.
I have seen this link here WP - Use file in plugin directory as custom Page Template? but does not seem to talk about the stage were Wordpress checks for custom templates in the themes directory and how to make it look else where.
It's not in the documentation because WordPress doesn't look elsewhere. Your best bet would be to create a template page in your theme folder, call it what you want, and then use include() to pull the contents of your template file in the plugins directory into the file in your theme directory, which would allow WordPress to see it.
I think the only other way to accomplish this would be to mess with Core, which is very bad practice.