Home › forums › WordPress Themes › Adding code to functions.php breaks Header/Footer (Anything with Visual Composer
This topic contains 36 replies, has 2 voices, and was last updated by Kevin Sobo 2 years, 4 months ago.
Website URL: https://vhprojects.nl/onlinebabyplants.com/shop/
Theme:
Purchase Code: Please provide correct purchase code
Hi,
We installed the plantmore theme and this works fine. We have a WooCommerce store running and want to show the out of stock products as last on our shop page.
This works with this code in other themes we have built/used:
class iWC_Orderby_Stock_Status{
public function __construct()
{
// Check if WooCommerce is active
if ( class_exists( ‘WooCommerce’ ) ) {
add_filter(‘posts_clauses’, array(
$this,
‘order_by_stock_status’
) , 2000);
}
}
public function order_by_stock_status($posts_clauses)
{
global $wpdb;
// only change query on WooCommerce loops
if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag()))
{
$posts_clauses[‘join’].= ” INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) “;
$posts_clauses[‘orderby’] = ” istockstatus.meta_value ASC, ” . $posts_clauses[‘orderby’];
$posts_clauses[‘where’] = ” AND istockstatus.meta_key = ‘_stock_status’ AND istockstatus.meta_value <> ” ” . $posts_clauses[‘where’];
}
return $posts_clauses;
}
}
new iWC_Orderby_Stock_Status;
However when adding this to our Plantmore (Child) functions.php it makes the footer and header disappear on our shop page. We think its cause of the Visual Composer that causes a bug but cant figure it out.
Could you look into this?
Thanks in advance!
Regards,
Alan
Hi,
Another issue.
The Visual Composer isnt the most recent version? But we cant update it because we don’t have a license for it? We expected each plugin to be the newest version by buying the theme, could you provide us the newest version of the Visual Composer?
At the moment the theme widgets (see screenshot: http://prntscr.com/l72841) don’t work when loading them in the visual composer.
It seems like something causes a bug for the VC.
Could you check this out too?
Regards,
Alan
Hi,
Can you provide for us FTP or Cpanel, Dashboard account and Code license ?
We will check it for you
Regards
RT Team
Hi,
we updated latest version VC for you. You can check again
Kind Regards
RT Team
Hi,
Thanks! But nothing changed sadly..
If you go into WPBakery Page Builder > Templates > Header 2 and try to click on Mini cart, Product Search (Dropdown), etc it pops up with a blank screen, indicating there’s still an error.
Also when I uncomment my Functions.php code the visual composer elements on the shop page also disappear.
It seems there’s a bug between the theme elements and the composer.
Hope you can check it out.
Thanks,
Alan
Hi,
Product Search (Dropdown), etc it pops up with a blank screen -> This only is short code to call to page. It doesn’t has option
Thanks!
Hi,
Okay clear.
What about the other Issue I mentioned? We have a WooCommerce store running and want to show the out of stock products as last on our shop page. This works with this code in other themes we have built/used:
class iWC_Orderby_Stock_Status{
public function __construct()
{
// Check if WooCommerce is active
if ( class_exists( ‘WooCommerce’ ) ) {
add_filter(‘posts_clauses’, array(
$this,
‘order_by_stock_status’
) , 2000);
}
}
public function order_by_stock_status($posts_clauses)
{
global $wpdb;
// only change query on WooCommerce loops
if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag()))
{
$posts_clauses[‘join’].= ” INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) “;
$posts_clauses[‘orderby’] = ” istockstatus.meta_value ASC, ” . $posts_clauses[‘orderby’];
$posts_clauses[‘where’] = ” AND istockstatus.meta_key = ‘_stock_status’ AND istockstatus.meta_value <> ” ” . $posts_clauses[‘where’];
}
return $posts_clauses;
}
}
new iWC_Orderby_Stock_Status;
However when adding this to our Plantmore (Child) functions.php it makes the footer and header disappear on our shop page. We think its cause of the Visual Composer that causes a bug but cant figure it out.
Thanks in advance!
Hi,
We added the header that came with the theme but not all widgets are working correctly. Our menu cart only shows when adding a product to the cart. Otherwise it’s not visible, see page:
https://vhprojects.nl/onlinebabyplants.com/shop/
It seems as if the items are not loaded in on page load.
Hi,
It’s back online!
Regards,
Alan
Hi,
We disabled plugin ( Disable Cart Fragments) and cart show normal.
You can check again.
Hi,
Thanks!
Our last issue is the one I mentioned as first in this. If you visit the shop page now, you can see the header & footer arent showing (visual composer) this happens when I insert the custom code in my functions.php to show the out of stock items as last. The code does do what it’s supposed to do.
Can you look into what might be causing this? Because on other websites where we use this code it doesnt crash the header and footer.
Thanks!
Regards,
Alan
Hi,
Have you got an update for us?
Thanks!
Regards,
Alan
Hi,
We see shop page works normal now. Have you fixed it ?
Thanks!
Hi,
We turned it off cause we needed to show the client the website.
I added the code to the functions again now. You can check what happens to the store page.
Regards,
Alan
Hi,
Can you provide for us Cpanel account ?
Thanks!
Hi,
Unfortunately thats not possible as it’s shared with other websites.
What do you need? Access to FTP? Database? We can create seperate login’s for that.
Regards,
Alan
Hi,
So, You can compress your website include both code and database then upload and provide link for us download
We will install on localhost and fix it for you
Thanks!
Hi,
We have tried best to fix it but we can’t find the reason. It doesn’t show errors so It’s difficult to fix
Can you turn off this feature ?
Thanks!
Hi,
Yes we already saw that.
We actually need this feature because our client specifically asked for it. We think it’s a problem with VisualComposer however, cause we didnt get a license key for VisualComposer with this theme, we can’t contact them..
Is there a direct way to contact them where they can offer support? Or can you contact them?
Thanks,
Regards,
Alan
Hi,
Another issue we have is that the site seems slow. This happened directly after installing the theme.
What can be done about this?
Regards,
Alan
We installed cache plugin and your website load well now. You can check again.
Thanks!
Hi,
This has sped it up a bit yeah, thanks!
One more issue, I managed to get an error code to be shown on the shop page where we want to add the functions.php code. Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in functions.php on line 73. This refered to the plantmore theme, not my child theme.
This might be causing the bug that deletes the Visual Composer parts when adding my custom code. However I cant find that constant on line 73 as its probably loaded in somewhere else.
Could you check that out? Thanks!
Hi,
We can’t connect to FTP.
You can find see it at line 73 in file functions.php our theme
You can change it $_SERVER[REQUEST_URI] to $_SERVER[‘REQUEST_URI’]
Hi,
That’s the thing, there isn’t such a code in your functions.php on that line 73, I couldnt find it. The error code isn’t displaying at the moment so maybe it was nothing.
We contacted WpBakery Pagebuilder (bought support for it) about the problem we had with the shop page but they said there plugin is working fine and that the problem that causes the header and footer to disappear isn’t because of their plugin.
They told us to contact you for a solution because it happens in your theme. We would like to get a solution for the problem (header and footer dissappearing when adding custom code to functions.php).
I look forward to the answer/help.
Regards,
Alan
UPDATE
We figured out that that line of code was caused by malware. It’s been solved now.
Now we only need help with the shop page
UPDATE 2:
Wpbakery disabled their plugin and the header and footer didnt load as raw text. This shows its not related to their plugin. Just something colliding in the header and footer files.
Hi,
I narrowed it down to the header.php and footer.php for the code to get mixed up with the code in our functions.php
In the header.php it’s the code from line 40 to 56 that doesn’t load (which contains the header template) and in the footer.php it’s the code from line 22 to line 39.
I think because both those codes and mine (in the functions.php) is getting stuff from the DB. If my code or yours could be loaded earlier or async I think it would be solved.
I just don’t know how to do that or alter your code to still make it load our header and footer templates.
Hope you can help us further.
Regards,
Alan
Hi,
Sorry, We have tried but We haven’t still fixed it yet
Regards
RT Team
Hi,
No problem, the site will be published live in a few days without the code but the test site will stay on the server we sent so it can be continued to test and fix.
Like I said, I think it’s because my code and your code is fetching data from the DB at the same time. Maybe there is a way to just hard code the header code instead of fetching the template from the db?
Hope you can solve it soon!
Regards,
Alan
Hi,
Any update on this what we could do?
Thanks
Hi,
We have tried hard but We haven’t found solution for the problem order by in shop page
Regards
RT Team
Hi,
Okay, have you got any advice on what else we can try?
Regards,
Alan
Hi,
Sorry. We haven’t fixed this. It conflicted with WPBakery
ps:
We don’t support here anymore. You can contact to mail: [email protected] to be supported from next time
Regards
RT Team
You must be logged in to reply to this topic.