Wrap php in shortcode

From Codex Shortcode Examples // In case there is opening and closing shortcode. echo do_shortcode(‘[iscorrect]’.$text_to_be_wrapped_in_shortcode.'[/iscorrect]’); Basically, you can’t use do_shortcode() two separate times for what is one shortcode consisting of a pair of tags. In your code you need to save your output to variables instead of using echo. Then at the end wrap it … Read more

Problem code and show comments

This question is very hard to understand but I think that you might need to put wp_reset_query() or wp_reset_postdata() after your Loop (after endwhile;) to to reset the loop and/or the $post variable.

Shortcode question…. javascript

WordPress offers a function called wp_localize_script. That function is your best friend for situations like yours. There are plenty of examples here. But I leave you with this good tutorial: http://pippinsplugins.com/use-wp_localize_script-it-is-awesome/

Is it possible to handle two or more shortcodes in a single page?

From the PHP Manual on require_once: The require_once statement is identical to require except PHP will check if the file has already been included, and if so, not include (require) it again. The second time your shortcode handler is run, the view/template will not be executed. Hence no output. Change require_once “/front_end/view/api-list.php”; to require “/front_end/view/api-list.php”; … Read more

Creating tabs shortcode

user2587741 posted an answer to their question inside the question: $tabs_divs=””; function tabs_group($atts, $content = null ) { global $tabs_divs; $tabs_divs=””; $output=”<div id=”tab-side-container”><ul”; $output.=’>’.do_shortcode($content).'</ul>’; $output.= ‘<div class=”panel-container”>’.$tabs_divs.'</div>’; return $output; } function tab($atts, $content = null) { global $tabs_divs; extract(shortcode_atts(array( ‘id’ => ”, ‘title’ => ”, ), $atts)); if(empty($id)) $id = ‘side-tab’.rand(100,999); $output=” <li> <a href=”#”.$id.'”>’.$title.'</a> … Read more

Replace shortcode with output in database?

First of all create a function that use get_shortcode_regex to get the post_content of a post with the shortcode replaced. Note that any other shoertcode will be untouched function get_replaced_sourcecode_sc( $post ) { if ( empty($post) ) global $post; if ( empty($post) || ! isset($post->post_content) ) return false; $content = $post->post_content; if ( preg_match_all( “https://wordpress.stackexchange.com/”. … Read more

Plugin or shortcode for ISBN number?

I’ve had some help from a developer, and would like to share the solution: function get_google_tag( $isbn_metadata ) { return ( /* ‘<span class=”post-meta-key”>Preview: </span>’ . */ ‘<script type=”text/javascript” src=”http://books.google.com/books/previewlib.js”></script>’ . ‘<script type=”text/javascript”>’ . ‘GBS_insertPreviewButtonPopup(\’ISBN:’ . $isbn_metadata . ‘\’);’ . ‘</script>’ ); }

shortcode – I need to throw a message or load a different page

Move your form processing code outside the shortcode so you can hook it to an earlier action before headers are sent, then you can do whatever redirection you need to after the form is processed. function process_int_form(){ if ( isset( $_REQUEST[‘int_prefix’] ) && isset( $_REQUEST[‘int_suffix’] ) ) { // process form wp_redirect( home_url( $_SERVER[‘REQUEST_URI’] ) … Read more