Hi i have this function inserted into functions.php in my theme:
function woocommerce_after_account_navigation(){
$html = '<h3>Title</h3>';
$html.='<li>Text1</li>';
$html.='<li>Text2</li>';
echo $html;
}
and have placed this hook into navigation.php file from WooCommerce templates
<?php do_action( 'woocommerce_after_account_navigation' ); ?>
but seems that dont show nothing from content that i placed into functions.php
Can someone help me what is wrong with this hook ?
Youn don't need to change anything in the My account templates (as you are using an existing hook)… To get your custom content displayed, you should need to make it this way:
add_action( 'woocommerce_after_account_navigation', 'custom_content_after_account_navigation' );
function custom_content_after_account_navigation(){
$html = '<h3>Title</h3>';
$html.='<li>Text1</li>';
$html.='<li>Text2</li>';
echo $html;
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested on WooCommerce 3 and works.
This custom content will be displayed below the My Account Menu
Related
I am using a licenced version of the WordPress Grooni Crane theme
https://crane.grooni.com/promo/
https://grooni.com/docs/crane/search/crane_before_primary_menu_area
I want to add content and images to a section ABOVE the Groovy Menu Plugin (comes with the Grooni theme).
So usually I would create te HTML of the images and content and forcefully add it into the header.php file before the menu gets shown, but upon doing this I saw that the PHP now allows for a content section to be added / displayed before the menu will be displayed using crane_before_primary_menu_area .
My question is: How / where in the Grooni Crane theme do I create / edit this section, so that I dont have to force the HTML into the header file, but so that it rather get added dynamicly using the proper functions.
Code in the header.php file looks like this:
do_action( 'crane_before_primary_menu_area' );
do_action( 'crane_primary_menu_area' );
do_action( 'crane_after_primary_menu_area' );
So it shows 'crane_before_primary_menu_area' first, then it shows the menu bar, and then it should show 'crane_after_primary_menu_area'.
My Question is where / how (on the wordpress CMS) do I create / edit a content section for 'crane_before_primary_menu_area' & 'crane_after_primary_menu_area'
This must be done through the child theme.
Together with the Crane theme It was bundled.
Activate it or create your own new one.
https://developer.wordpress.org/themes/advanced-topics/child-themes/
Insert the hook into the functions.php file that will be called in the action 'crane_before_primary_menu_area'
Sample contents of functions.php for child theme
<?php
if ( ! function_exists('custom_func__crane_before_primary_menu_area')) {
add_action( 'crane_before_primary_menu_area', 'custom_func__crane_before_primary_menu_area' );
function custom_func__crane_before_primary_menu_area() {
$html_content = '<div>Content before menu area</div>';
echo $html_content;
}
}
In the above example, we assigned HTML text to the variable
$html_content = '<div> Content before menu area </div>';
And immediately it was shown to the front
echo $html_content;
However inside the function
function custom_func__crane_before_primary_menu_area () {.......}
you can call any other available functions, and display any content you wish.
I am using Woocommerce Storefront theme and I want to replace the original header with a custom header that I created in elementor. I have a shortcode for the new header but I don't know how to insert it into the code. I am using a blank storefront child theme and there is a function.php file and style.css file.
Thanks for the help.
Just copy the header.php from the parent theme and paste it inside the child theme. Then you can already put your custom code in it.
Reference: codex.wordpress.org/Child_Themes
You can do this in your child theme by using a hook on init
Something like this:
add_action('init', 'replace_header' );
function replace_header(){
remove_action( 'storefront_header', 'storefront_primary_navigation', 50 );
add_action('storefront_header', 'my_custom_header', 50);
}
function my_custom_header(){
do_shortecode('[your_elementor_header_shortcode attr1="value1"]')
}
I would like to remove downloads menu from my account page.
How can I do this? Is it any hook to remove a specific item from the menu?
Thanks.
Go to WooCommerce > Settings > Advanced and remove the entry for Downloads in the Account endpoints section, just leave it blank. And the menu will not be visible anymore.
You will need this lightly customized this code snippet:
function custom_my_account_menu_items( $items ) {
unset($items['downloads']);
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'custom_my_account_menu_items' );
This code goes on function.php file of your active child theme (or theme) or in any plugin file.
This code is tested and working
[data-tab="downloads"] {
display: none!important;
}
I want add Prettyphoto to my blog and I prepare filter:
add_filter( 'wp_get_attachment_link', 'sant_prettyadd');
function sant_prettyadd ($content) {
$content = preg_replace("/<a/","<a rel=\"prettyPhoto[slides]\"",$content,1);
return $content;
}
But where I should looking file function.php ?
When WordPress is integrated into Magento, the functions.php file is not used, which means that any code you add to it won't have any effect on the frontend of your blog.
The integration extension is Magento based and uses Magento templates to display your blog. You probably want to add the preg_replace function call to the post view template. This can be found at the following location:
app/design/frontend/base/default/template/wordpress/post/view.phtml
To make changes to this file, first copy it to your custom theme and edit it there. Look for the following line:
<?php echo $post->getPostContent() ?>
This is the code that retrieves the post content. You can use the preg_replace call here to achieve what you're trying to do.
I'm trying to remove some hooks so that product categories don't show up on the homepage (of a Wordpress Storefront child theme).
I have the following code in my functions.php, which isn't working:
/**
* REMOVE SECTIONS ON HOMEPAGE
*/
add_action( 'init', 'remove_storefront_on_sale_products', 10 );
function remove_storefront_on_sale_products () {
?>
remove_action( 'homepage', 'storefront_on_sale_products', 60 );
<?php
}
Your code aint working because your line remove_action() is located outside of the php-tags.
Remove ?> and <?php in your above code and you should be fine.
First of all wordpress has not any action like "homepage" so you need to verify which action you are calling so if you want to remove function output only from homepage then you can do it by conditionally and secondly you didn't write proper php code, To achieve this you can write following in method.
if(!is_home()){
//Do stuff here if it is not homepage
}
OR
if(get_the_ID()!=101){ //101 your page id in which you don't want to show this
//Do stuff here if it is not homepage
}
I hope this may help you.