Tag Info

Hot answers tagged

4

Without seeing your code it is difficult to give you an exact answer. There is the shortcode_atts_{$shortcode} filter that was introduced in Wordpress 3.6. All attributes is run through this filter. It has to be noted that the $shortcode parameter needs to be set in shortcode_atts. I haven't seen shortcodes yet that has this parameter set though. Your ...


3

Here's just an addition to the answer by @PieterGoosen. There are few methods how one could modify the post type of WP_Query, that's inside a shortcode. Let's assume it's [recent_posts]. Method A) If the shortcode uses the third parameter of the shortcode_atts() (as @PieterGoosen mentioned) for example wpse, then: /** * Method A: Using the ...


3

You need a couple of things. A shortcode handler, and a custom query: function wpse_186346_excerpt_length() { return 50; } function wpse_186346_excerpt( $atts ) { $atts = wp_parse_args( $atts, array( 'posts_per_page' => 2, // Any other default arguments ) ); // We don't need paging, always save a ...


3

They're probably referring to the functions file in your theme, functions.php. This file is loaded by WordPress during setup, and gives you an opportunity to do things or register hooks and filters. Note that this file is optional, and not every theme has a functions.php, if that's the case just create one yourself Keep in mind the only thing that's special ...


2

Simple, make a shortcode: function my_image() { $image = get_field('imagen_superior'); if( !empty($image) ) { echo '<img src="' . $image['url'] . '" alt="' . $image['alt'] . '" />'; } } function my_shortcode( $attr ) { return '<div class="header-image">' . my_image() . '</div>'; ...


1

What if you concatenate the string, like $author_ig = '[instagram-feed id="' . get_the_author_meta('instagram') . '" imageres="full" showheader="true" showbutton="true" buttoncolor="#fff" buttontextcolor="#000" showfollow="false"]'; echo do_shortcode($author_ig); I used get_the_author_meta instead of the_author_meta, because the former returns the ...


1

Yes it is possible. There are two ways that I can think of at this moment. First follow what the codex says Shortcodes. Basically you just wrap your html in ob_start(); this will return the html as a string so you can echo it. function my_shortcode() { ob_start(); ?> <HTML> <here> ... <?php return ob_get_clean(); } The ...



Only top voted, non community-wiki answers of a minimum length are eligible