New answers tagged

0

Gradient and boxshadow are fine to put inline. Your trouble will be with the hover states. Luckily there is a trick. You can put the hover styles in an outer element and force inherit on hover. Like this: <div class="myshortcode"> <a style="color:blue;"><span style="color:red;">Content</span></a> </div> In your ...


0

You can add this below code in your function.php file function content_formatter($content){ $new_content = ''; $pattern_full = '{(\[raw\].*?\[/raw\])}is'; $pattern_contents = '{\[raw\](.*?)\[/raw\]}is'; $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($pieces as $piece) { if ...


0

Okay, I think I've figured out what you're actually asking. You're asking what the variable for the bit between the shortcodes. If that is all you are asking, then the answer is the parameter variable $content. You are already processing it in your code. Also, in your example, you seem to have a third shortcode, [caption] that you aren't processing. Is that ...


3

I think you could get around this by pre-running the shortcodes on the page by applying the content filters before the header is output. This should allow any internal shortcodes run inside the included post to add any action hooks properly and thus any needed stylesheets/resources. add_action('wp_loaded','maybe_prerun_shortcodes'); function ...


3

This may be a silly idea, but it might work: 1 Let your shortcode explode to an iframe with a custom query_var (tutorial). Like this: <iframe src="http://www.example.com/?p=123&my_query_var=content_only"></iframe> 2 In your single.php detect the query_var and in that case skip visual header, sidebars, footer - anything not connected to ...


2

Load visual compose css function get_visual_composer_style($id) { return '<style>' . get_post_meta( $id, '_wpb_shortcodes_custom_css', true ) . '</style>'; } Load css based on shortcode function custom_shortcode_scripts() { global $post; if( is_a( $post, 'WP_Post' ) && has_shortcode( ...


1

the_content is usually "executed" in the context of a loop when all relevant global data is set. You should try to mimic it by using code like function get_page_content(){ global $post; $id = $_REQUEST['id']; $post = get_page($id); setup_postdata($post); echo apply_filters('the_content', $post->post_content); //echo ...


0

This is pretty straightforward as far as shortcodes go: function wpse_226998_post_author( $atts, $text ) { if ( ! empty( $atts['id'] ) && $atts['id'] == get_the_author_meta( 'ID' ) ) return $text; } add_shortcode( 'post_author', 'wpse_226998_post_author' ); And in practice: [post_author id="8"]This post is by author ID ...


1

First, don't echo your php, but assemble everything in a string, let's say $titlestring. Next, make this string available for access by the javascript (the slug is the one you used to register the script): $params = array ( 'titlestring' => $titlestring, ); wp_localize_script ('your-script-slug', 'IframeTitle', $params); Finally, access the ...


1

wp_login_form is completely separate from wp-login.php - the login_form hook only applies to the latter. For the former, you've got three filters at your disposal: login_form_top - return HTML to be injected right after the opening <form /> tag login_form_middle - return HTML to be injected between the password field and the remember me/submit field ...


0

Your shortcode is not echoing the html in the right way. You have <span class="icon"> <img ...> </span> <span class="text"> <span class="title"> ... </span> <span class="description"> ... </span> </span> In this way you cannot put icon and title inline. You need: <span ...


2

The closest to a reference technique in core would be [gallery] shortcode. If you look at the source of implementing gallery_shortcode() function you'll see that it: Generates instance number (so multiple shortcodes can be distinguished). Outputs dynamic CSS inline into a page source, for each instance. I wouldn't consider it particularly neat solution, ...


1

Shortcodes are backend stuff, so you can't just change values of shortcodes itself in editor with jQuery, the thing you can do is to call both shortcodes, hide one of them, and on click show him and hide other one. It all depends what do you want to do, but one of the option is to hide them like this and in this case use classes also with display:none


0

If you are missing terms, maybe try to show all terms, event those that are not assigned to a post. By default, wordpress does not get terms that are not in a post. get_terms($taxonomy, array('hide_empty' => false));


0

For inherited parent theme you need to add Template lines in child theme. Please read this https://codex.wordpress.org/Child_Themes /* Theme Name: Twenty Fifteen Child Theme URI: http://example.com/twenty-fifteen-child/ Description: Twenty Fifteen Child Theme Author: John Doe ...


3

I tested following code and it worked just fine for me: function my_name_shortcode( $atts ) { return "<h3>PRASAD</h3>"; } add_shortcode( 'name', 'my_name_shortcode' ); add_filter( "the_excerpt_rss", "do_shortcode" ); The result can be seen in below screenshot.


-1

Just replace your short code function with given code. Then call it as usual. It should work perfectly now. //registering the shortcode to show testimonials function load_testimonials($a){ $atts = shortcode_atts( array( 'rand' => '', 'max' => '', 'id' => '', ), $a); $args = array( "post_type" => ...


0

Yo don't need to write a plugin for that - what you need already exists. Check this link: https://wordpress.org/plugins/list-categories/ With this plugin you can display categories in any post or page. Of course, maybe you want to write your own plugin, and in that case this link can be helpful. I hope that this will help you to speed up a process.


0

I've modified your code to reflect the wp_list_categories() function reference as suggested by @Usce. This snippet will create an unordered list, remove the "Categories" list title, and add the li class with individual category ID so you can target each link in the list. function catting ($atts, $content = null) { echo '<div id="cats" ...


-1

There is build in wordpress function for that , so you can use wp_list_categories() for that. Please refer here to learn more And after you display them you an do some CSS if you want to display it as buttons. I hope this helps. Kind regards, Usce


0

Solution I find a workaround for this issue. I post it for posterity. This is an issue, several issue, between divi and REST Api. In the exemple bellow, register_rest_field is used instead of register_rest_route, but the fix is valid for both method. This solution could not be very futureproof. But, at least, their is no modification inside Divi Builder ...


6

For the permanent solution, your SQL query is slightly off - you need: UPDATE db1357924680.wp_posts SET post_content = REPLACE( post_content, '[print_me]', '' ) WHERE post_content LIKE '%[print_me]%' MySQL replace example


4

There is an easier way to do this: add_filter( 'the_content', 'my_post_content_remove_shortcodes', 0 ); function my_post_content_remove_shortcodes( $content ) { /* Create an array of all the shortcode tags. */ $shortcode_tags = array( 'shortcode_1', 'shortcode_2', 'shortcode_3' ); /* Loop through the shortcodes and ...


0

Based on your updated question and comments, this should be what you are looking for: function wpse_225078_wpbd_tags( $tags ) { $tags['one_time_link'] = one_time_link(); return $tags; } add_filter( 'wpbe_tags', 'wpse_225078_wpbd_tags' ); The idea is to hook into the tag system provided by WPBE so you can just use %one_time_link% in your email ...


0

Availability of shortcodes defined by plugins at any point of the code is undefined expect for (and even that is a maybe) singular content. In most cases outside of that context you better call the function implementing it with the applicable parameters instead of "parsing" the shortcode.


1

To enable shortcodes in text widgets add a filter like that: add_filter( 'widget_text', 'do_shortcode' ); You can pass every string to do_shortcode() including get_theme_mod() calls. echo do_shortcode( get_theme_mod( 'theme_setting' ) );



Top 50 recent answers are included