How can I add space between shortcode and Contact us page in the header of the theme. I was able to add the shortcode successfully. Now I am unable to add the gap between shortcode and contact us.
Below I have attached the code to this header file. After
do_action( 'ciyashop_header_nav_content' );
I have added echo do_shortcode('[searchandfilter id="2819"]'); thats my shortcode.
<?php do_action( 'ciyashop_before_header_nav' );?>
<div class="<?php ciyashop_header_nav_classes('header-nav');?>">
<div class="header-nav-wrapper">
<?php
/**
* Functions hooked into ciyashop_before_header_nav_content action
*
* #hooked ciyashop_before_header_nav_content_wrapper_start - 10
*/
do_action( 'ciyashop_before_header_nav_content' );
/**
* Functions hooked into ciyashop_header_nav_content action
*
* #hooked ciyashop_category_menu - 10
* #hooked ciyashop_catmenu_primenu_separator - 15
* #hooked ciyashop_primary_menu - 20
*/
do_action( 'ciyashop_header_nav_content' );
/* echo do_shortcode('[searchandfilter id="2819"]'); */ My Shortcode
/**
* Functions hooked into ciyashop_after_header_nav_content action
*
* #hooked ciyashop_after_header_nav_content_wrapper_end - 10
*/
do_action( 'ciyashop_after_header_nav_content' );
?>
</div>
Related
Please forgive me if my phrasing is confusing. I am pretty new to PHP and still don't understand it very well.
I am editing content-single.php on my child theme of storefront.
I have made some custom fields and I would like them to be located inside the content of my post.
but I can only manage to get it above or below the content.
Here is my code:
<?php
/**
* Template used to display post content on single pages.
*
* #package storefront
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
do_action( 'storefront_single_post_top' );
the_field('test');
/**
* Functions hooked into storefront_single_post add_action
*
* #hooked storefront_post_header - 10
* #hooked storefront_post_content - 30
*/
do_action( 'storefront_single_post' );
/**
* Functions hooked in to storefront_single_post_bottom action
*
* #hooked storefront_post_nav - 10
* #hooked storefront_display_comments - 20
*/
do_action( 'storefront_single_post_bottom' );
?>
</article><!-- #post-## -->
Thanks for any help!
Try this in functions.php
add_filter('storefront_post_content', 'add_acf', 10, 1);
function add_acf( $value ) {
$value = get_field('test');
return $value;
};
I ended up just using elementor for this particular issue
I am trying to re-position the Woocommerce message
"X Product" HAS BEEN ADDED TO YOUR CART.
But with no success. I tried with the hooks like these
remove_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );
add_action( 'woocommerce_before_single_product_summary', 'wc_print_notices', 10 );
The above did not work at all.
Any suggestion will be appreciated.
Edit
I also tried to call the template tag directly in the content-single-product.php file somewhere at the bottom like this
<?php wc_print_notices(); ?>
Still no message shows at the desired place.
<div class="summary entry-summary">
<?php
/**
* woocommerce_single_product_summary hook.
*
* #hooked woocommerce_template_single_title - 5
* #hooked woocommerce_template_single_rating - 10
* #hooked woocommerce_template_single_price - 10
* #hooked woocommerce_template_single_excerpt - 20
* #hooked woocommerce_template_single_add_to_cart - 30
* #hooked woocommerce_template_single_meta - 40
* #hooked woocommerce_template_single_sharing - 50
*/
do_action( 'woocommerce_single_product_summary' );
?>
</div><!-- .summary -->
<php wc_print_notices();?>
To remove it you could just hide it with CSS:
.woocommerce-message, .woocommerce-info { display:none; }
Or to reposition:
//Remove Message:
remove_action( 'woocommerce_before_single_product', 'woocommerce_show_messages' );
//Show message call this function where you want the message displayed
woocommerce_show_messages();
//Might be a very late but to people looking still you could try these.
remove_action( 'woocommerce_before_single_product', 'woocommerce_output_all_notices', 10 );
add_action('woocommerce_before_single_product','your_function_name');
function your_function_name(){
//your code here
}
//Here is the template that returns the output notices
//if you want to include in the banner as well
<div class="woocommerce-notices-wrapper">
<?php wc_print_notices(); ?>
</div>
I am trying to reorder the hooks in WooCommerce.
I try to display first the sidebar and then the content. Currently it loads first the products and then the sidebar:
Here are hooks and I have also attached the output the source code:
<?php
/**
* woocommerce_sidebar hook.
*
* #hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
?>
<?php
/**
* woocommerce_after_main_content hook.
*
* #hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
I need to redesign the default woocommerce template of a product page.
I have tried this with copying the structure of avada to child-theme.
/theme/avada/woocommerce/single-product/* to /theme/avada-child-theme/woocommerce/single-product/
But I can not find a template that displays the whole page. Only title.php does change the title. But can not find the rest of the page.
I need to delete these parts:
- short description
- sku
- social media buttons
How can I redesign a complete product page is new for me.
May be someone can give me a start where to find the templates.
Thanks in advance.
Herman
<?php
/**
* The template for displaying product content in the single-product.php template
*
* This template can be overridden by copying it to yourtheme/woocommerce/content-single-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
* will need to copy the new files to your theme to maintain compatibility. We try to do this.
* as little as possible, but it does happen. When this occurs the version of the template file will.
* be bumped and the readme will list any important changes.
*
* #see http://docs.woothemes.com/document/template-structure/
* #author WooThemes
* #package WooCommerce/Templates
* #version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<?php
/**
* woocommerce_before_single_product hook.
*
* #hooked wc_print_notices - 10
*/
do_action( 'woocommerce_before_single_product' );
if ( post_password_required() ) {
echo get_the_password_form();
return;
}
?>
<div itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?>" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
/**
* woocommerce_before_single_product_summary hook.
*
* #hooked woocommerce_show_product_sale_flash - 10
* #hooked woocommerce_show_product_images - 20
*/
do_action( 'woocommerce_before_single_product_summary' );
?>
<div class="summary entry-summary">
<?php
/**
* woocommerce_single_product_summary hook.
*
* #hooked woocommerce_template_single_title - 5
* #hooked woocommerce_template_single_rating - 10
* #hooked woocommerce_template_single_price - 10
* #hooked woocommerce_template_single_excerpt - 20
* #hooked woocommerce_template_single_add_to_cart - 30
* #hooked woocommerce_template_single_meta - 40
* #hooked woocommerce_template_single_sharing - 50
*/
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
do_action( 'woocommerce_single_product_summary' );
?>
</div><!-- .summary -->
<?php
/**
* woocommerce_after_single_product_summary hook.
*
* #hooked woocommerce_output_product_data_tabs - 10
* #hooked woocommerce_upsell_display - 15
* #hooked woocommerce_output_related_products - 20
*/
do_action( 'woocommerce_after_single_product_summary' );
?>
<meta itemprop="url" content="<?php the_permalink(); ?>" />
</div><!-- #product-<?php the_ID(); ?> -->
<?php do_action( 'woocommerce_after_single_product' ); ?>
I don't know about the Avada theme, but in default WooCommerce you can see in the content-single-product.php template that short description and social buttons are added via hook. So to remove them you'd need to use remove_action() from your theme's functions.php.
If this doesn't work as is, please review remove_action() because you just need to make sure that the parameters match up to what the Avada theme is doing.
function so_35252579_remove_hooks(){
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
}
add_action( 'woocommerce_before_single_product', 'so_35252579_remove_hooks' );
To remove the SKU, you could either disable skus, or if you need them but don't want to display them on the front end then you would need to override single-product/meta.php
Here is the code. You can write it as a plugin or simply copy paste to functions.php. Note the following
locate_template function is first look at active theme root directory for the file. If the file is present there then it will use. otherwise plugin folder will be check.
First if condition simply checking whether the current page is showing is single product page. you can add more conditional tags based on you requirement.
add_filter( 'wc_get_template_part', 'so_29984159_custom_content_template_part', 10, 3 );
function so_29984159_custom_content_template_part( $template, $slug, $name ){
if ( $slug == 'content' && $name == 'single-product') {
if( locate_template('content-single-product-custom.php') ) {
$template = locate_template( $file_name );
} else {
// Template not found in theme's folder, use plugin's template as a fallback
$template = dirname( __FILE__ ) . '/content-single-product-custom.php';
}
}
return $template;
}
I'm trying to change the layout of woocommerce single product page.
Just want to change the title, excerpt and add to cart button position. ( title and excerpt before the image, button below the image ).
What I have now
What I'm looking for
The layout of the page is decided in woocommerce with templates and with the WordPress actions within the templates. You will probably have to use a combination of css, removing and adding actions and changing the template.
The templates are located in wp-content/plugins/woocommerce/templates/. The most important template for your situation is content-single-product.php. These templates can be overwritten in the theme by placing your own template files with the same name in wp-content/themes/yourtheme/woocommerce. I'd recommend the following:
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
Then
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_excerpt', 15 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
In addition to that in the custom template you make in your theme, you wrap do_action( 'woocommerce_before_single_product_summary' ); in it's own div. You float this div left and give it the same grey background. This div contains anything outputted at the woocommerce_before_single_product_summary action. The div with class image you may need to stop that from floating left.
From the outside that's about as specific as we can get.
EDIT: Here's the content-single-product.php file with div of class before-single-product-summary added to wrap the action.
<?php
/**
* The template for displaying product content in the single-product.php template
*
* Override this template by copying it to yourtheme/woocommerce/content-single-product.php
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<?php
/**
* woocommerce_before_single_product hook
*
* #hooked wc_print_notices - 10
*/
do_action( 'woocommerce_before_single_product' );
if ( post_password_required() ) {
echo get_the_password_form();
return;
}
?>
<div itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?>" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="before-single-product-summary">
<?php
/**
* woocommerce_before_single_product_summary hook
*
* #hooked woocommerce_show_product_sale_flash - 10
* #hooked woocommerce_show_product_images - 20
*/
do_action( 'woocommerce_before_single_product_summary' );
?>
</div>
<div class="summary entry-summary">
<?php
/**
* woocommerce_single_product_summary hook
*
* #hooked woocommerce_template_single_title - 5
* #hooked woocommerce_template_single_rating - 10
* #hooked woocommerce_template_single_price - 10
* #hooked woocommerce_template_single_excerpt - 20
* #hooked woocommerce_template_single_add_to_cart - 30
* #hooked woocommerce_template_single_meta - 40
* #hooked woocommerce_template_single_sharing - 50
*/
do_action( 'woocommerce_single_product_summary' );
?>
</div><!-- .summary -->
<?php
/**
* woocommerce_after_single_product_summary hook
*
* #hooked woocommerce_output_product_data_tabs - 10
* #hooked woocommerce_upsell_display - 15
* #hooked woocommerce_output_related_products - 20
*/
do_action( 'woocommerce_after_single_product_summary' );
?>
<meta itemprop="url" content="<?php the_permalink(); ?>" />
</div><!-- #product-<?php the_ID(); ?> -->
<?php do_action( 'woocommerce_after_single_product' ); ?>
Then you add this css:
.before-single-product-summary{
float: left;
background: #3c3f4e;
}
.product .images{
float: none;
}
I can't guarantee this modification will fix your problem but it will start you down the right track.
We need to look at the content-single-product.php template file. Here are the two sections we we need to look at in that file:
Located: plugins/woocommerce/templates/content-single-product.php
<?php
/**
* woocommerce_before_single_product_summary hook.
*
* #hooked woocommerce_show_product_sale_flash - 10
* #hooked woocommerce_show_product_images - 20
*/
do_action( 'woocommerce_before_single_product_summary' );
?>
<div class="summary entry-summary">
<?php
/**
* woocommerce_single_product_summary hook.
*
* #hooked woocommerce_template_single_title - 5
* #hooked woocommerce_template_single_rating - 10
* #hooked woocommerce_template_single_price - 10
* #hooked woocommerce_template_single_excerpt - 20
* #hooked woocommerce_template_single_add_to_cart - 30
* #hooked woocommerce_template_single_meta - 40
* #hooked woocommerce_template_single_sharing - 50
*/
do_action( 'woocommerce_single_product_summary' );
?>
</div><!-- .summary -->
The two action we can see here -
The first action that is for product image is -
1] woocommerce_before_single_product_summary
The second action outputs the product title is -
2] woocommerce_single_product_summary
Let’s pull the title out of the summary block and place it in the block that precedes it so the product title is above the product images.
Step 1: Remove action from woocommerce_single_product_summary -
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
Step 2 : Add action into woocommerce_before_single_product_summary -
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 5 );