Skip to content

Instantly share code, notes, and snippets.

View themeblvd's full-sized avatar

Jason Bobich themeblvd

View GitHub Profile
@themeblvd
themeblvd / functions.php
Created May 20, 2017 20:42
When using a theme with Theme Blvd framework 2.5+, this will adjust search results to use the post grid display.
<?php
/**
* Display search results in a grid.
*/
function my_the_loop_args( $args ) {
if ( is_search() ) {
$args['context'] = 'grid';
<?php
/**
* Up sell product display. Override Woo's woocommerce_upsell_display().
*
* @since 2.5.0
*/
public function up_sell() {
$args = apply_filters('themeblvd_woocommerce_up_sell_args', array(
'posts_per_page' => '-1',
@themeblvd
themeblvd / functions.php
Last active May 2, 2017 19:02
When using Theme Blvd WordPress Framework, replace the category output in a post showcase with a custom field.
<?php
/**
* Add custom field after current <span class="item-title">
*/
function my_item_info( $output ) {
$output .= sprintf( '<span class="tagline">%s.</span>', esc_html( get_post_meta( get_the_ID(), 'my_custom_field', true ) ) );
return $output;
}
@themeblvd
themeblvd / functions.php
Created March 2, 2017 20:20
When using Theme Blvd Framework 2.5+ theme and WooCommerce, change number of related product columns (i.e. up-sells on single product pages).
<?php
/**
* Change number of related product columns
* on single product pages.
*/
function my_up_sell_args( $args ) {
themeblvd_set_att( 'woo_product_columns', 2 );
return $args; // Pass $args through untouched.
@themeblvd
themeblvd / functions.php
Last active February 20, 2017 21:05
When using the footer "template sync" option at Appearance > Theme Options > Layout > Footer, this is how you can translate that footer template for a second language in WPML.
<?php
/**
* Apply separate footer sync template when WPML
* language is French (fr).
*/
function my_translated_footer( $config ) {
if ( defined( 'ICL_LANGUAGE_CODE' ) && 'fr' === ICL_LANGUAGE_CODE ) {
$template = 'your-template-name'; // Put the name of your French template here.
@themeblvd
themeblvd / functions.php
Created February 20, 2017 20:52
How to display section labels from the layout builder interface on the frontend of your website when the custom layouts are displayed.
<?php
/**
* Print labels at the start of a section
* in the layout builder.
*
* @param string $section_id ID of current section.
* @param string $layout_id ID of current layout the section is in.
* @param array $data All of the section's display opion data.
*/
function my_section_top( $section_id, $layout_name, $data ) {
@themeblvd
themeblvd / functions.php
Last active February 5, 2017 21:54
Add template part option to post display elements in Theme Blvd Layout Builder. -- Later, we can add to this a way to actually apply the option by creatively filtering themeblvd_template_part or with new filter proposed #224 in Jump Start repo.
<?php
/**
* Add template part option to post display
* elements.
*/
function my_elements( $elements ) {
$option = array(
'id' => 'part',
'name' => __('Template Part (Optional)'),
@themeblvd
themeblvd / template.php
Last active February 5, 2017 21:50
Here's an example of calling themeblvd_loop() directly. In the Theme Blvd Framework, all loops are passed through the themeblvd_loop() function. It's very powerful. To see all parameters check out the top of the function at /framework/includes/loop.php.
<?php
themeblvd_loop(array(
'query' => 'post_type=portfolio_item&posts_per_page=-1', // Custom query, must be a string unfortunately.
'context' => 'showcase', // blog, list, grid, or showcase
'display' => 'masonry_filter', // showcase (no pagination), paginated, masonry, or masonry_filter.
'filter' => 'portfolio', // What taxonomy the the masonry filter menu uses.
'columns' => 2 // Number of columns in showcase.
));
<?php if ( $other_properties_query->have_posts() ) : ?>
<?php
$counter = 1; // Start counter at 1.
$total = $other_properties_query->post_count; // Set total number of posts.
?>
<h2>Under Construction</h2>
<?php themeblvd_open_row(); // Open first row before starting loop. ?>
@themeblvd
themeblvd / functions.php
Created January 18, 2017 17:16
Create a custom set of column number selections for the Post Grid element.
<?php
/**
* Create a custom set of column number
* selections for the Post Grid element.
*/
function my_elements( $elements ) {
$elements['post_grid']['options']['columns']['options'] = array(
'1' => __( '1 Column' ),
'2' => __( '2 Column' ),