Skip to content

Instantly share code, notes, and snippets.

@shazdeh
Created December 5, 2013 07:03
Show Gist options
  • Save shazdeh/7801290 to your computer and use it in GitHub Desktop.
Save shazdeh/7801290 to your computer and use it in GitHub Desktop.
Builder: display modules above the post content
<?php
function custom_builder_frontend_display_setup() {
global $ThemifyBuilder;
remove_filter( 'the_content', array( $ThemifyBuilder, 'builder_show_on_front' ), 11 );
add_filter( 'the_content', 'custom_builder_frontend_display', 11 );
}
add_action( 'template_redirect', 'custom_builder_frontend_display_setup' );
function custom_builder_frontend_display( $content ) {
global $post, $wp_query;
global $ThemifyBuilder;
if ( ( is_post_type_archive() && ! is_post_type_archive( 'product' ) ) || post_password_required() || isset( $wp_query->query_vars['product_cat'] ) || is_tax( 'product_tag' ) ) return $content;
if ( is_post_type_archive( 'product' ) && get_query_var( 'paged' ) == 0 && $ThemifyBuilder->builder_is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
$post = get_post( woocommerce_get_page_id( 'shop' ) );
}
$meta_key = apply_filters( 'themify_builder_meta_key', '_themify_builder_settings' );
$builder_data = get_post_meta( $post->ID, $meta_key, true );
$builder_data = stripslashes_deep( maybe_unserialize( $builder_data ) );
if ( ! is_array( $builder_data ) || strpos( $content, '#more-' ) ) {
$builder_data = array();
}
$content = $ThemifyBuilder->retrieve_template( 'builder-output.php', array( 'builder_output' => $builder_data, 'builder_id' => $post->ID ), '', '', false ) . $content;
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment