New answers tagged

0

You need to "include" the WordPress functions which then will convert your shortcode from [mycode] to the code you expect. You do this by including wp-blog-header and setting wp_use_themes to false, this then stops the header.php of the theme from being added. define('WP_USE_THEMES', false); require ('./wp-blog-header.php'); You will need to change the ...


0

<iframe src=https://test.com/video/112/[currentuser_username] width="800" height="450"> <p>Your browser does not support iframes.</p> </iframe> Simply removing the quotes around everything worked. All modern browsers add these back in - when that stops working (doubt anytime soon) we might have to create some advanced shortcode ...


0

You've got the $content available to you in your remove_p function - so inside that function just look for the existence of a special string (i.e. your "shortcode"), to allow the filter to do the str_replace. For example: if ( false !== strpos( $content, "[p-filter]") ) { $paragraphs = array("<p>","</p>","[p-filter]"); $...


0

I think you can simplify your code a lot, by just using: $episode_number = ( $query->found_posts - $query->current_post ); in the loop as the episode's number. So you don't need that problematic Get_Post_Number() function and there's no need to use a special shortcode for this.


0

It seems you need to rest the post data before return the $postCount. Before return it, add the follow: wp_reset_postdata(); -- There is a difference between wp_reset_query()and wp_reset_postdata(), as explained here. wp_reset_query() - ensure that the main query has been reset to the original main query. wp_reset_postdata() - ensures that the global $...


1

First, check the quotes: <?php echo do_shortcode('[enlarge_text small="A" medium="A" large="A" default_value="medium"]'); ?>


0

Alternate Method The author of Metaslider suggests using WP Mobile Detect. Here is a sample of code I used to achieve a similar result to what I think you are looking for. Requires the WP Mobile Detect plugin. <?php if(shortcode_exists('metaslider') && function_exists(wpmd_is_notphone) && wpmd_is_notphone()): echo(...


0

Not a shortcode, but <?php echo get_option( 'blogname' ); ?> does the trick niciely


0

I rewrote the function based on a few other posts I have seen online and now have the following code which works without any errors. I am still open to any further suggestions on the best way to streamline this code even further it it can be. Thanks again function downloads_shortcode($atts){ extract(shortcode_atts(array( 'download_type' => '' ), $...


0

As far as I know, ARVE is no longer necessary to use. As well, Wordpress does not add p nor br tags ever. So if they are being added, you probably have a third party editor which adds them or maybe a custom function. Either way, you can probably disable that feature.


0

Since version 4.9 visual composer added shortcode lazy loading. To use VC shortcodes on AJAX content use this function before printing the content WPBMap::addAllMappedShortcodes();. So below code may help you, function get_page_content(){ $id = $_REQUEST['id']; $page_data = get_page($id); WPBMap::addAllMappedShortcodes(); echo ...


0

After theme's setup Ask for filter's removal All in child's getup -- Brain is getting hot Bold assuming approval Best Haiku it's not


4

Try the filters in your functions.php: add_filter( 'the_excerpt', 'shortcode_unautop'); add_filter( 'the_excerpt', 'do_shortcode'); Props: @bainternet (Source) Or, use your own filter on get_the_excerpt. Put this in your theme's functions.php: function custom_excerpt($text = '') { $raw_excerpt = $text; if ( '' == $text ) { $text = ...


0

If you take a look at native galleries they already have IDs with counter implemented: $instance++; ... $selector = "gallery-{$instance}"; ... $gallery_div = "<div id='$selector'class='gallery... So first gallery within a post will have <div id="gallery-1"... and so on. This is used by core itself to target different styles at each instance. If you ...


1

Don't remember exactly when (4.3?) core had gone with a much more restrictive parsing of shortcodes due to many security problems that the lax parsing with combination of poorly implemented shortcodes had created. The end result is that you can not use a shortcode in an attribute. The right solution is to have a shortcode that produces the whole iframe. ...


2

I would not use custom fields or shortcodes for this functionality, I would look at filters. the_content filter and the loop_end action (just make sure that your theme uses while ( have_posts() ) in single post pages) comes to immediate mind here. These are two options which requires no modification of any of your files in your theme. This way you can add ...


1

Quickest way is actually to make a standalone php file (wrap the code in <?php CODE ?> and save it in your /wp-content/mu-plugins/ directory, eg, I often use a site-shortcodes.php... WordPress will auto-load the file, and your functionality will be independent of the theme you use. otherwise if the functionality is tied in to your theme specifically ...


0

Instead of do_shortcode you can use the run_shortcode function of $wp_embed global $wp_embed; $embed = $wp_embed->run_shortcode( '[embed]' . $url . '[/embed]' ); echo $embed;


0

I often do an output buffering, and that works for me. Let's take a look at this example. Not tested. And, esc_attr() will take care of all sorts of escaping for bad user inputs. <?php /** * Container shortcode * * Outputs a container wrapping the content. * * @param array $atts Array of shortcode attributes. * @param string $content ...


0

I just tested this code and it appears to be working. Though as others have stated you are missing a semicolon at the end of margin-bottom, which you may want to add to be semantically correct. With that being said, to get the code to output exactly how you want when entered into the WYSIWYG, without additional p tags wrapping the Text, you should add a ...


0

I wasn't able to directly add a repeating field (with let's say a + button) but I was able to create a 2 step process whereby the end-user can use a numeric field to set the number of repeatable areas on the next screen: Step 1 - Select Shortcode Step 2 - Shortcode Builder Step 1/2 Step 3 - Shortcode Builder Step 2/2 Step 4 - Shortcode Output into ...


0

Gallery Image Captions - Hide/Show I just recalled this caption toggle question, when I was writing this answer, so let me rewrite it a little bit to work for this question. Let's introduce the caption_toggle attribute for the native gallery shortcode, that takes a comma separated string of bool values. It's possible to hide the captions with CSS, but ...


0

Adding another way here. You can leave this to WordPress and just pass the URL from the_content filter. Example:- $adresgoeshere = 'URL of oembed providers' echo apply_filters('the_content', $adresgoeshere);


2

As you are using URLs from oEmbed provides (YouTube, Vimeo, Soundcloud, etc), I would use wp_oembed_get() function. This function uses oEmbed and tries to get the embed HTML of the provided URL. $embed = wp_oembed_get( $some_url ); if( $embed ) { echo $embed; } else { // The embed HTML couldn't be fetched }


1

There are several aspects and as always, performance is something that have to be taken in a context. Pieter's answer gives you one - "do you even have a (better) way to achieve the required functionality". going beyond that, there are some facts that is worth to keep in mind Modern PHP is fast. It is never a good thing to write inefficient code but it is ...


1

You need to look at this from a couple of perspectives and then you have to weigh the odds against each other In general, shortcodes will be slower (we are talking milliseconds here) as they need to be parsed and processed by the shortcode handler. USAGE: [my_shortcode] in post editor Shortcodes in general are quite useful and usally outweigh the fact ...


0

High level description of what I ended doing, it is actually not too bad to do such an implementation and save you the effort of having different code for the widget and customizer forms, but there are many small details to take care of. Store settings as a meta values for the post Create proper customizer sections Associate the section with a "virtual" ...


0

If your not called shortcodes, this means they not called their functions and therefore it no affect performance of your website. Also you can use static class and variables to reduce load to your site. Every shortcode will be use function only one time, independently how many times you call it.


0

Found a solution. Adding this code below to the functions.php file of your theme will do the trick. if ( ! isset( $content_width ) ) $content_width = YOUR WIDTH HERE;


4

I wonder if you could override the [rev_slider] with this kind of wrapper: add_shortcode( 'rev_slider', function( $atts = array(), $content = '' ) { $html = ''; // Your custom banner HTML $banner = '<div id="bannerHTML"><!-- banner HTML goes here --></div>'; // Append your banner HTML to the revslider's output if( ...


2

This is a solution I've come up with after refining it a bit. The below should only run if the shortcode exists in the content. It loops through all the shortcodes to find the specific one we need, replaces it with the shortcode plus the new HTML: function insert_after_shortcode( $content ) { if( ! has_shortcode( $content, 'shortcode_name' ) ) { ...


2

This happens when there is echoed output from the shortcode rather than the result being returned... I'd wager nt_course_note_entry_field likely echoes rather than returns. If there is one - or you can create one) - use a similar function like nt_get_course_note_entry_field that does not echo. If you can't change the function you can wrap it in an output ...


2

the_permalink(), the_title() by default echo their value. As you want to store that value in a variable you will need to return the values instead. get_the_permalink(), get_the_title() are two similar functions that return the value instead of echo. So you new code may look something like this: $list = '<li class="ubermenu-submenu ubermenu-submenu-id-...


0

Ok, I found the solution. First of all, you have to $handle = popen('env python '. DIR . '/' . $data['file'], 'r'); More importantly, I had to install Python 2.7.2 on Bluehost


0

I believe the problem is you are not calling do_shortcode() in the output buffer. You don't need to be running the loop within the output buffer since I can assume get_content_template() simply returns HTML with embedded shortcodes. Save that to a string variable, then run that through the do_shortcode() and save the echoed output to the buffer. This is ...


0

Try do_shortcode( get_the_content() ); or apply_filters( 'the_content', get_the_content() ); in your post file.


2

Well, yes, you can do that: //replace live edited content to display html editor.on('BeforeSetcontent', function(event){ event.content = tinymce_to_html( event.content ); }); //Transform your html content to raw content editor.on('GetContent', function(event){ event.content = html_to_tinymce( event.content ); }); Let's explain that: Under the ...



Top 50 recent answers are included