Adding custom shortcode to page leads to page without styling

Shortcodes need to return their values, but the_content() echoes the post content. So you have two options. First is to capture all output and then return it at the end: ob_start(); // Start capturing output; while( $loop->have_posts() ) { $loop->the_post(); the_content(); }; wp_reset_postdata(); return ob_get_clean(); // Return captured output; That will be the cleanest way … Read more

How create a shortcode with html

Please use below code function html_show($atts) { $makearr = explode(“,”,$atts[‘content’]); if(isset($makearr) && !empty($makearr)) { foreach($makearr as $arrval){ $stringli .= ‘<li>’. $arrval.'</li>’; } } else { $stringli = ”; } $htmlcode=”<div class=”notify”><span class=”symbol icon-fact”></span> <strong>A kind of a notice box !</strong><ul>”.$stringli.'</ul> </div>’; return $htmlcode; } add_shortcode( ‘htmltag’, ‘html_show’ ); /*******Using method*******/ echo do_shortcode(‘[htmltag content=”message1,message2,message3,message4″]’);

Enclose article’s body with default shortcode

Thanks to @kero I have implemented this code: <?php echo do_shortcode(‘[responsivevoice voice=”Italian Female” buttontext=”Ascolta”]’.'<br>’.$bodyContent.'[/responsivevoice]’); ?> The $bodyContent variable contains the HTML value of the article’s body, obtained using this function: http://www.web-templates.nu/2008/08/31/get_the_content-with-formatting/index.html <?php $bodyContent = get_the_content_with_formatting(); ?>

How to Create Short Code Using Custom Post type

Try this /** * Register all shortcodes * * @return null */ function register_shortcodes() { add_shortcode( ‘listing’, ‘shortcode_mostra_produtos’ ); } add_action( ‘init’, ‘register_shortcodes’ ); /** * Produtos Shortcode Callback * * @param Array $atts * * @return string */ function shortcode_mostra_produtos( $atts ) { global $wp_query, $post; $atts = shortcode_atts( array( ‘type’ => ” ), … Read more

A number appears inside a div called wpb_wrapper, when I use a custom shortcode

You can’t return an include like that. A successful include() itself returns 1, and since you’re returning the return value of include, your shortcode is displaying “1”. Handling Returns: include returns FALSE on failure and raises a warning. Successful includes, unless overridden by the included file, return 1. — http://php.net/manual/en/function.include.php If you want to output … Read more

Next and Previous Pagination button not displaying in WordPress

You’re using a custom query (new WP_Query), so you need to pass $tyler_query->max_num_pages (the max pages) to the next_posts_link() function — more details here: next_posts_link( null, $tyler_query->max_num_pages ) And btw, no need to echo with previous_posts_link() because the function indeed echoes the output. I.e. Just do so: <?php previous_posts_link(); ?>. Also, you should add paged … Read more

Embedding BitBucket Code in Posting

Here try the below code, it should give you a good start. // requrires 3 arguments // user, project, path // usage e.g: [bitbucket user=”jespern” project=”django-piston” path=”piston/utils.py”] function bitbucket_code( $atts ) { extract( $atts ); global $post; $path_to_name = str_replace(“https://wordpress.stackexchange.com/”, “_”, $path); $meta_key = “bitbucket_{$user}_{$project}_{$path_to_name}”; $code = get_post_meta( $post->ID, $meta_key, true ); if ( !$code … Read more

Shortcode append to the the_content()

What your asking for can’t be done using shortcodes. <article> isn’t a part of the content, its part of the theme and it ‘contains’ the content. Thus shortcodes cannot modify it or move those tags around. Shortcodes by definition are part of the content, so anything they add on the end is also a part … Read more