the_excerpt filter doesn’t work as expected

Generating the excerpt is quite a jumble of filters, so it’s difficult to see precisely what is happening, but here is my guess: WordPress attaches a default filter (see line 148) to get_the_excerpt, namely wp_trim_excerpt. As you can see from the latter function’s source code, it starts with getting the content if it gets passed … Read more

Shortcode is not working

It looks like you are trying to apply a shortcode to the title field. That is not supported by itself (only shortcodes in the post content are evaluated automatically), but easily remedied by adding it as a filter to get_the_tile in your plugin: add_filter (‘the_title’, ‘do_shortcode’); (I’m assuming that you ruled out other possible problems … Read more

Override static method in WC_Shortcodes class (shortcode) [closed]

This is how you can (or should) remove the default Shortcode: // Hook after `WC_Shortcodes::init()` is executed. add_action( ‘init’, function(){ // Remove the shortcode. remove_shortcode( ‘product_categories’ ); // Add it back, but using our callback. add_shortcode( ‘product_categories’, ‘my_product_categories_shortcode’ ); }, 11 ); And here’s how you can modify the default Shortcode’s output: function my_product_categories_shortcode( $atts … Read more

Why shortcode always displayed after footer not in body

Ahmad, a shortcode needs to return the html, not echo it directly like a widget does. Shortcodes work because wordpress replaces the [shortcode] with the text returned by the shortcode function. So change the code to something like: $html=”<h3>Tulisan terbaru website kebudayaan…</h3>”.date(‘j F Y’); $blogs = get_last_updated(); $html .='<table class=”widefat” cellspacing=”0″>’; foreach ($blogs AS $blog) … Read more

Add JS in footer via shortcode?

I’ll address your address and thruthfully you should probably be enqueuing this, and consider using wp_add_inline_script() or wp_localize_script(). However, if you can’t be bothered to do that for some reason, you can just remove the return of your shortcode, and instead use add_action(‘wp_footer’, ‘…’);. This is actually similar to how I enqueue registered scripts/styles only … Read more

How to add “get_theme_mod” inside a shortcode?

I would comment, but lack the pointage… You seem to be on the right track: I see that your shortcode callback and the function are named differently: (f_gallery_shortcode / function_gallery_shortcode). Try this: add_shortcode( ‘ui_gallery’,’function_gallery_shortcode’ ); function function_gallery_shortcode(){ $dynamic_h1 = “<h1>” . get_theme_mod(‘dynamich1’) . “</h1>”; return $dynamic_h1; } now using [ui_gallery] in your posts, should return … Read more