Skip to content

Instantly share code, notes, and snippets.

@Musilda
Musilda / gist:c4218e7eca1e6c447392
Created February 22, 2016 11:44
WooCommerce - Display Price For Variable Product With Same Variations Prices
// Display Price For Variable Product With Same Variations Prices
add_filter('woocommerce_available_variation', function ($value, $object = null, $variation = null) {
if ($value['price_html'] == '') {
$value['price_html'] = '<span class="price">' . $variation->get_price_html() . '</span>';
}
return $value;
}, 10, 3);
add_action( 'init', 'set_virtual' );
function set_virtual(){
$args = array(
'post_type' => 'product',
'posts_per_page' => -1
);
$products = new WP_Query( $args );
var_dump(count($products->posts));
#Do not copy&paste whole file, find only interesting parts!
#HTTP authentification
AuthType Basic
AuthName "Log in"
AuthUserFile /path/to/.htpasswd
Require valid-user
#Security headers
<?php get_header(); ?>
<div class="col-8">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="title"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="post-content">
<?php echo the_excerpt();?>
<?php if ( ! is_active_sidebar( 'main-sidebar' ) ) : ?>
<div class="widget widget_search"><!--BEGIN #searchform-->
<form method="get" id="searchform" action="/">
<fieldset>
<input type="text" name="s" id="s" value="search" onfocus="if(this.value=='search')this.value='';" onblur="if(this.value=='')this.value='search';" />
<input type="submit" name="submit" value="" id="s-submit">
</fieldset>
<!--END #searchform-->
</form>
/*
Theme Name: Dummy Theme
Theme URI:
Author: Toret.cz
Author URI: https://toret.cz/
Description: Theme for Metal Trade eshop
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: dummy-theme
<?php
if ( ! function_exists( 'dummy_theme_setup' ) ){
function dummy_theme_setup() {
// Add theme supports
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'html5', array(
<!DOCTYPE html>
<!-- BEGIN html -->
<html <?php language_attributes(); ?>>
<!-- BEGIN head -->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="https://gmpg.org/xfn/11">
<?php get_header(); ?>
<div id="primary" class="content-area col-8">
<main id="main" class="site-main" role="main">
<div class="error-404 not-found">
<header class="page-header">
<h1 class="page-title"><?php esc_html_e( 'Oops! That page can&rsquo;t be found.', 'theme' ); ?></h1>