Skip to content

Instantly share code, notes, and snippets.

View wpexplorer's full-sized avatar
✍️
We create themes & plugins and run a popular blog about WordPress.

WPExplorer wpexplorer

✍️
We create themes & plugins and run a popular blog about WordPress.
View GitHub Profile
add_action( 'pre_get_posts', function( $query ) {
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
$excluded_pages = array( 'PAGE_1_ID', 'PAGE_2_ID' );
set_query_var( 'post__not_in', $excluded_pages );
}
} );
add_filter( 'wpex_{YOUR_POST_TYPE_NAME}_entry_media_lightbox', '__return_true' );
add_filter( 'wpex_cpt_entry_supported_media', function( $media_types ) {
$media_types[] = 'gallery';
return $media_types;
} );
add_filter( 'body_class', function( $class ) {
if ( function_exists( 'is_shop' ) && is_shop() ) {
$class[] = 'shop-page';
}
return $class;
} );
/**
* Returns correct theme button classes based on args.
*
* @since 3.2.0
*/
function wpex_get_button_classes( $style = array(), $color = '', $size = '', $align = '' ) {
$args = $style;
if ( ! is_array( $args ) ) {
add_action( 'wpex_hook_content_top', function() {
echo '<div class="entry wpex-mb-25" style="font-size:16px;">';
wpex_card( 'list-1', array(
'title' => 'This is a custom title',
'excerpt' => 'This is a custom excerpt',
'image' => 'http://localhost/total/wp-content/uploads/sites/5/2019/05/us-air-force-77909-150x150.jpg',
) );
add_action( 'wpex_hook_site_logo_inner', function() { ?>
<a href="PAGE LINK" class="my-second-logo"><img src="URL of the image" /></a>
<?php }, 40 );
@wpexplorer
wpexplorer / gist:99101389770798af7c3a15c39c4dd620
Created July 29, 2020 01:48
Total | Open custom links in a new tab
// Open custom links in a new tab
add_action( 'wp_footer', function() { ?>
<script>
jQuery( '.entry.has-redirect' ).each( function() {
var $this = jQuery( this );
$this.find( '.entry-title a, .entry-media a, .entry-readmore-wrap a' ).attr( {
'target' : '_blank',
'rel' : 'noopener noreferrer'
} );
@wpexplorer
wpexplorer / gist:fbeca9e61514f74bd5763d437c9f4b15
Created July 27, 2020 19:08
Disable custom Contact Form 7 pre-loader in Total
add_filter( 'wpex_localize_array', function( $array ) {
$array['altercf7Prealoader'] = false;
return $array;
} );
$string = WPSEO_Meta::get_value( 'title', $post_id );
if ( ! empty( $string ) {
$replacer = new WPSEO_Replace_Vars();
return $replacer->replace( $string, get_post($post_id) );
}