.main-navigation .main-nav ul li[class*="current-menu-"] > a:after{
position: absolute;
bottom: calc(50% - 1.5em);
height: 0;
width: 0;
left: -webkit-calc(50% - 8px);
left: calc(50% - 10px);
border: 9px solid rgba(0,0,0,0);
border-bottom-color: currentcolor;
content: "";
}
manuel
Shortcode to show usernamein WordPress
function show_loggedin_function( $atts ) {
global $current_user, $user_login;
get_currentuserinfo();
add_filter('widget_text', 'do_shortcode');
if ($user_login)
return '<div class="mw-logged-in-info">Hallo ' . $current_user->display_name . ' <br><a href="https://vhe-shop2.wp8-demo.de/mein-konto/">Mein Konto</a> </div>';
else
return 'Sie haben noch kein Konto? <a href="/login/">Login / Registrieren</a>';
}
add_shortcode( 'show_loggedin_as', 'show_loggedin_function' );
Replace / Translate Text in WordPress
function multi_change_translate_text( $translated ) {
$text = array(
'Old Text 1' => 'New Text 1',
'Old Text 2' => 'New Text 2',
'Old Text 3' => 'New Text 3',
);
$translated = str_ireplace( array_keys( $text ), $text, $translated );
return $translated;
}
add_filter( 'gettext', 'multi_change_translate_text', 20 );
GeneratePress – auto close mobile menu when scrolling
<script>
document.addEventListener( 'scroll', function( e ) {
const openedMenus = document.querySelector( '#mobile-header' );
const btn = openedMenus.querySelector( 'button.menu-toggle' );
if(openedMenus.classList.contains('toggled')){
btn.click();
}
} );
</script>
GenerateBlocks – Headline Divider
/* GB HEADLINE DIVIDER */
.mw-heading-divider {
position: relative;
}
.mw-heading-divider-left:before, .mw-heading-divider-center:before {
content: "";
position: absolute;
top: -.8em;
left: 0;
height: 2px;
width: 100px;
background: #454545;
}
.mw-heading-divider-center:before {
left: 50%;
transform: translatex(-50%);
}
WP Show Posts and Advanced Custom Fields
add_action( 'wpsp_before_content', function( $settings ) {
if ( 123 === $settings['list_id'] ) {
$meta = get_post_meta( get_the_ID(), 'test_acf_field', true );
if ( $meta ) {
add_action( 'wpsp_before_content', function( $settings ) {
if ( 100 === $settings['list_id'] ) {
$meta = get_post_meta( get_the_ID(), 'test_field', true );
if ( $meta ) { echo '<div class="wpsp-meta-1">'; } echo $meta; echo '</div>'; }
} );
add_action( 'wpsp_before_content', function( $settings ) {
if ( 287 === $settings['list_id'] ) {
$meta_datum = get_post_meta( get_the_ID(), 'acf-termin-datum', true );
$meta_beschreibung = get_post_meta( get_the_ID(), 'acf-termin-beschreibung', true );
if ( $meta_datum ) {
echo '<h2>'; }
echo $meta_datum;
echo '</h2>';
if ( $meta_beschreibung ) {
echo '<p>'; }
echo $meta_beschreibung;
echo '</p>';
}
} );
replace 123 with the ID of the WPSP list
add_action( 'wpsp_before_content', function( $settings ) {
if ( 100 === $settings['list_id'] ) {
$meta = get_post_meta( get_the_ID(), 'test_field', true );
if ( $meta ) { echo '<div class="wpsp-meta-1">'; } echo $meta; echo '</div>'; }
} );
add_action( 'wpsp_after_content', function(){
echo get_field('the_advanced_custom_field');
});
WPSP Hooks
wpsp_before_wrapper
wpsp_before_header
wpsp_before_title
wpsp_before_content
wpsp_after_content
wpsp_after_wrapper
Display Pods Custom Field
<php echo get_post_meta (get_the_ID(), 'auto', true); ?>
Antispam Shortcode for Email Adress
function mw_email_shortcode( $atts , $content = null ) {
if ( ! is_email( $content ) ) {
return;
}
$content = antispambot( $content ); $email_link = sprintf( 'mailto:%s', $content ); return sprintf( '<a href="%s">%s</a>', esc_url( $email_link, array( 'mailto' ) ), esc_html( $content ) );
}
add_shortcode( 'email', 'mw_email_shortcode' );
[email]email@adress.com[/email]
Link column / container with css
.clickable {
position: relative;
}
.clickable a:after {
content: "";
display: block !IMPORTANT;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
}