New answers tagged

0

I found the solution, I had to do the right ajax actions... For the second dropdown, I had to first detect the click on the statically created div then detect the change on the dynamically created dropdown. Here the correct code: <?php /** * Plugin Name: demoConnecteurs * Description: Plugin de démo des connecteurs Jenkins et Mantis **/ ...


3

Here's one way: You can look at has_shortcode() and find the parsing there: preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER ); using the get_shortcode_regex() function for the regex pattern. For non empty matches, you can then loop through them and collect the full shortcode matches with: $...


2

If you only need the Shortcodes without the attributes, you can use this function: function get_used_shortcodes( $content) { global $shortcode_tags; if ( false === strpos( $content, '[' ) ) { return array(); } if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { return array(); } // Find all registered ...


-2

If you are looking to add heading and banner on pages then work on header.php file in your theme. You can also add classes to body tag by using filter hooks https://developer.wordpress.org/reference/functions/body_class/ add_filter( 'body_class', 'custom_class' ); function custom_class( $classes ) { if ( !is_front_page() ) { $classes[] = '...


0

You can use somthing like this: function my_custom_shortcode( $atts ) { // Attributes $atts = shortcode_atts( array( 'word' => 'example', // the word which will be replaced 'part' => '1' // for identifing the different texts ), $atts, 'textblock' ); // only if a word exists ...


1

You're using $post->ID, but haven't defined $post anywhere. You either need to specify global $post;, to get the current post in the loop, or define it some other way. But the best way to get this ID would just be to use get_the_ID(): <?php $sub_heading = get_post_meta( get_the_ID(), 'sub_heading', true ); ?>


0

You can’t do what you’re trying to do. If you want to output a shortcode you need to do it in the content or template. You can’t place one with CSS.


0

You can create a custom shortcode wrapper that will execute the shortcode with the desired attributes, so you would use [jobs-custom] in the page: add_shortcode('jobs-custom', 'custom_jobs_shortcode'); function custom_jobs_shortcode($atts) { if (is_user_logged_in()) { $per_page = get_user_meta(get_current_user_id(), 'jobs-per-page', true); }...


0

Oh, I didn't thought it would be that easy. So when I am storing the html in a variable "$htmlContent" and echo the variable in my template I can just wrap the variable in the do_shortcode() function echo do_shortcode($htmlContent); Maybe this answer are useful for other with the same problem.


-1

My solution was, and perfectly works fine for me function my_function(){ ob_start(); echo 'Long html tag here'; $output = ob_get_contents(); ob_end_clean(); return $output; }


0

I was able to solve this by installing a plugin called Custom Content Shortcode then using a code snippet like this right from the page editor: [raw] [users role=um_custom_role_1] [pass user_fields=fullname] [mkdf_team team_name="{FULLNAME}" ... etc data settings] [/pass] [/users] [/raw] Where: [raw] is just a code wrapper for ...


0

I am guessing your are talking about customizing the look of the output from the shortcode to match the design of the page better is that correct? If so then I would style it using Firebug and CSS.


0

The problem you're facing is because of the nature of the WordPress redirect. It uses what is called a safe redirect, namely with the function wp_safe_redirect(). This restricts redirects to local URLs only. Your work around for this is the following where you jump into the login redirect filter and perform your desired redirection then, before WordPress ...


0

If you have a shortcode string saved, try echoing it with do_shortcode function, which turns shortcodes into content. $saved_shortcode = get_option( 'my_customizer', 'copyright' ); if ( $saved_shortcode && is_string( $saved_shortcode ) ) { echo do_shortcode( $saved_shortcode ); } More about the function on the developer handbook, https://developer....


0

Another workaround that you could do is creating a widget of this paragraph. You will need to install a plugin as described in: How to Add WordPress Widgets in Post and Page Content You can now make a text widget of this paragraph and just add [do_widget paragraph] on all your pages where you want to show the paragraph. (the word paragraph in this example ...


1

I don’t see any issue with the OOP code that would cause it not to work. I think the problem is with the shortcode itself. I don’t believe shortcodes can have spaces. Show Form is not a valid shortcode name. [Show Form] would be parsed as as a shortcode named Show with an attribute Form. The conventional format for this shortcode would be show_form.


0

I would recommend using single quotes if you want to include some HTML, also you need to return something otherwise nothing happens. // WP Shortcode function text_shortcode() { return '<strong>bold text:</strong> <a href="https://wordpress.stackexchange.com/questions/318934/shortcode-returns-escaped-html-tags">See wordpress....


1

There is an error in the solution provided by @adedoy, since $slug is never defined. This worked for me: function include_file($atts) { $atts = shortcode_atts( array( 'path' => 'NULL', ), $atts, 'include' ); ob_start(); get_template_part($atts['path']); return ob_get_clean(); } add_shortcode('include', 'include_file');


0

Put the code below in your functions.php file: function register_theme_shortcodes() { add_shortcode( 'category', /** * category shortcode function. * * @param array $atts * * @return string */ function ( $atts ) { $atts = shortcode_atts( array( ...


0

The main problem with your code is that you register [categorypost] shortcode, but you want to register it as [category]. Another problem is that your shortcode should return HTML code - the output of shortcode. And as you can see here, the get_the_category function returns an array of terms. So how to write it correctly? The easiest way will be to use ...


0

The only way I could figure out how to get do_shortcode working was by using WP_Query. <?php // get current site $args = [ 'p' => $post_id, 'post_type' => 'any' ]; // site wp query $oSite = new WP_Query($args); ?> <?php if ( $oSite->have_posts() ): ?> <?php while($oSite->have_posts()): $oSite->...


0

The problem is that the PHP function include (roughly speaking) echoes the content and then returns a boolean value. If you switch the include for file_get_contents then your $output will be a string of the file content rather than the boolean value indicating the success of the inclusion. Works for me with Wordpress5.2 & PHP7.


0

function show_the_views_func( $atts ){ $atts = shortcode_atts( array( 'placeholder' => '', ), $atts ); $count = get_post_meta( get_the_ID(), 'views', true ); return $count . $atts['placeholder'] . ' views'; } add_shortcode( 'show-the-views', 'show_the_views_func' ); echo do_shortcode( '[show-the-views ...


0

The problem is that you're attempting to use the arguments for the jQuery AJAX API with the native Fetch API. Specifically, the problem is that the JS Fetch API doesn't support a data argument. For an admin-ajax.php request to work in WordPress the $_REQUEST['action'] property needs to be populated, and to do this with the Fetch API you need to pass a ...


0

I'm not too familiar with BuddyPress and a total stranger to rtmedia. But out of curiosity I had a brief look at their documentations. Perhaps you could add a custom shortcode to your functions.php, which gets the current profile ID and uses it with the rtmedia gallery shortcode to display videos from the profile. Something along these lines, function ...


Top 50 recent answers are included