avatar
Hamza Afridi
0

Codes

5

Answers

Code compilers

Top answers

0
htaccess to remove index.php from url
November-22-2023
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
0
don't show out of stock products in woocommerce
November-22-2023
// Hide out of stock products from catalog
add_action( 'pre_get_posts', 'hide_out_of_stock_products' );

function hide_out_of_stock_products( $query ) {
if ( ! $query->is_admin && $query->is_main_query() && ( $query->is_post_type_archive( 'product' ) || $query->is_tax( get_object_taxonomies( 'product' ) ) ) ) {
$meta_query = $query->get( 'meta_query' );
if ( ! is_array( $meta_query ) ) {
$meta_query = array();
}
$meta_query[] = array(
'key' => '_stock_status',
'value' => 'outofstock',
'compare' => '!=',
);
$query->set( 'meta_query', $meta_query );
}}
0
remove add to cart woocommerce button
November-22-2023
//remove add cart button from single product page
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

//remove add cart button from Shop page
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
0
rename add to cart button woocommerce
November-22-2023
// To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' ); 
function woocommerce_custom_single_add_to_cart_text() {
    return __( 'Buy Now', 'woocommerce' ); 
}
// To change add to cart text on product Shop/archives(Collection) page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );  
function woocommerce_custom_product_add_to_cart_text() {
    return __( 'Buy Now', 'woocommerce' );
}
0
link external php to html
November-22-2023
 <html>
  <head>
  	<title> An External PHP File</title>
  </head>
  <body>
  	<?php include(" welcome.php "); ?>
  <body>
</html>

<!--Or You can use require-->

 <html>
  <head>
  	<title> An External PHP File</title>
  </head>
  <body>
  	<?php require(" welcome.php "); ?>
  <body>
</html>