Skip to content

Instantly share code, notes, and snippets.

/* CSS for responsive product tabs in WooCommerce. See my blog post here: https://www.timrosswebdevelopment.com/responsive-product-data-tabs-woocommerce */
/* For small screens only */
@media screen and (max-width: 767px) {
.woocommerce-tabs.woocommerce-tabs-responsive ul li {
/* this rule needs to be important to override the default woocommerce style */
display: flex !important;
flex-direction: column;
width: 100%;
}
@timrross
timrross / tabs.php
Last active January 16, 2024 11:35
<?php
/* CSS for responsive product tabs in WooCommerce. See my blog post here: https://www.timrosswebdevelopment.com/responsive-product-data-tabs-woocommerce */
/**
* Filter tabs and allow third parties to add their own.
*
* Each tab is an array containing title, callback and priority.
*
* This is a woocommerce template override and should be added to your custom theme in the following location:
* wp-content/themes/<YOUR-THEME>/woocommerce/single-product/tabs/tabs.php
*
@timrross
timrross / two-column-layout.css
Last active April 24, 2019 08:26
A simple vanilla javascript class to implement a two column, left-to-right layout.
.article {
width: 50%;
float: left;
clear: left;
.article.right {
float: right;
clear: right;
}
<?php
/**
* Check the orderby param for the particular REST API for hte custom post type.
* If it is set to a particular meta_ket, then set the orderby and meta_key query args/
* @link https://www.timrosswebdevelopment.com/wordpress-rest-api-order-by-meta_value/
*/
function filter_rest_accommodation_query($query_vars, $request) {
$orderby = $request->get_param('orderby');
if (isset($orderby) && $orderby === 'number_of_beds') {
$query_vars["orderby"] = "meta_value_num";
@timrross
timrross / contact-form-7-bootstrap.html
Created August 30, 2018 11:32
Contact Form 7 with Bootstrap 4 form
<div class="row">
<div class="col">
[response]
</div>
</div>
<div class="row">
<div class="form-group col">
<label for="your-name" class="control-label">Name <span class="text-danger">*</span></label>[text* your-name class:form-control id:name placeholder "Your Name"]
</div>
@timrross
timrross / order-by-menu-order.php
Last active June 6, 2022 19:51
Enable orderby custom parameter in WP REST API
<?php
/**
* The filter is named rest_{post_type}_collection_params. So you need to hook a new filter for each
* of the custom post types you need to sort.
* @link https://www.timrosswebdevelopment.com/wordpress-rest-api-post-order/
*/
// This enables the orderby=menu_order for Posts
add_filter( 'rest_post_collection_params', 'filter_add_rest_orderby_params', 10, 1 );
// And this for a custom post type called 'portfolio'