How to activate a plugin on the activation of a theme?

I highly doubt that what is happening is actually process of “activation” in WP terminology. What plugin is likely doing is just filtering data for what theme is currently active, without actually activating/deactivating (which would probably lead to chaotic collisions between different visitors). The easiest way to hide those shortcodes would probably be to make … Read more

What is this format called (nested shortcodes)?

I would use the phrase Nested Shortcodes to describe it. You can find many questions using that phrase here on WPSE. The Codex also uses it, for example here: http://codex.wordpress.org/Shortcode_API#Nested_Shortcodes Since the shortcodes in your example are related to the layout, we could perhaps call it: Nested Layout Shortcodes to be more specific. If you … Read more

Echo HTML in custom shortcode

I don’t know what “this isn’t working” means but a shortcode should not echo anything. You should concatenate a string and return it. if (is_single()){ $str=””; if($type == ‘audio’){ $str .= ‘<div class=”sub-audio”><h6 class=”sub_btn”>Audio</h6>’; } if($type == ‘video’){ $str .= ‘<div class=”sub-video”><h6 class=”sub_btn”>Video</h6>’; } foreach ( $bookmarks as $bookmark ) { $str .= sprintf( ‘<a … Read more

Basic do shortcodes question

the_field() is an ACF function and will echo content. It follows the WordPress (somewhat) pattern whereby functions with the_ at the front will echo content and functions beginning with get_ return content. Displays the value of the specified field. (this is the same as “echo get_field($field_name)”) http://www.advancedcustomfields.com/resources/functions/the_field/ Using the wrong function, as you have, will … Read more

Shortcode in my childtheme is not working

Reading your question, I think you are calling [get_employee] directly from a PHP template file in your child theme. This is not the way shortcodes work. You have three options: Put [get_employee] in the content of a post Run do_shortcode(“[get_employee]”) wherever you want in a template file Call directly the function callback wherever you want … Read more

Capitalize Shortcode Value on Output

Try this out. . . function cwc_pkmn( $atts = array(), $content=”” ) { // ———————— // Settings: $path=”https://wordpress.stackexchange.com/path/to/file/”; $ext=”png”; // ———————— // Shortcode input: $atts = shortcode_atts( array( ‘name’ => ” ), $atts, ‘pkmn_shortcode’ ); // Sanitize input: $name = esc_attr( $atts[‘name’] ); // Init: $words_ucfirst = array(); // Capitalize the first letter in each … Read more

Using Shortcode to Grab Archive Listing, Separate by Year

I found this answer: http://www.stemlegal.com/strategyblog/2011/wordpress-wednesdays-better-archive-lists-in-wordpress/ And the final code looks something like this: function getarchives_filter($where, $args) { if (isset($args[‘year’])) { $where .= ‘ AND YEAR(post_date) = ‘ . intval($args[‘year’]); } return $where; } add_filter(‘getarchives_where’, ‘getarchives_filter’, 10, 2); function my_archives($params, $content = null) { extract(shortcode_atts(array( ‘type’ => ‘style1’ ), $params)); $currentyear = date(‘Y’); $years = range(‘2012’,$currentyear); … Read more

Why can’t I display attachment_image_src with Custom Size?

With wp_get_attachment_image_src you get a array with values corresponding to the (0) url, (1) width, (2) height, and (3) scale of an image attachment (from the wordpress doc). you code can be: if($imageid){ $image_attributes = wp_get_attachment_image_src( $imageid, ‘custom-size-01’, false); echo “<img src=\””; echo $image_attributes[0]; echo “\” width=\”100%\” >”; }

shortcode issue in the_excerpt

Okay, I finally found it the answer. You need to add two filters to your functions.php file in order to run shortcodes through it. add_filter( ‘the_excerpt’, ‘shortcode_unautop’); add_filter( ‘the_excerpt’, ‘do_shortcode’);

run shortcode in excerpt of single custom post type

You just forgot to return the excerpt for the other post types. Try for example: function do_my_shortcode_in_excerpt( $excerpt ) { if ( ‘services’ == get_post_type() ) $excerpt = do_shortcode( wp_trim_words( get_the_content(), 55 ) ); return $excerpt; } add_filter( ‘get_the_excerpt’, ‘do_my_shortcode_in_excerpt’ );