How to create a shortcode with HTML code in it and custom parameters/

As per the shortcode documentation, your shortcode callback recieves any parameters set by the user in a $atts variable. You can combine them with any default values you might have with shortcode_atts(). function newsletter( $atts ) { $atts = shortcode_atts( array( ‘url’ => ‘https://domain.com/newsletter/z2o7q6’, // change default value as needed ‘headline’ => ‘Newsletter Box Headline’, … Read more

Shortcode Attributes – post__not_in array

With this part: ‘post__not_in’ => array($custom_atts[‘hide’]) you’re actually running: ‘post__not_in’ => array( “7043,7128” ) with [customposts hide=”7043,7128″]. Note that post__not_in expects an array of numbers, not an array with a single CSV element. Have a look at e.g. wp_parse_id_list() and don’t forget to validate the input, to e.g. avoid empty input or a one with … Read more

What does this shortcode do?

In all honesty, it doesn’t do very much. If the code is literally as you describe, all it does is add fullstops either side of the content. If that’s not what happens then there’s likely missing code. As for the other parts: What is extract? extract is a PHP function used in a lot of … Read more

WordPress shortcode plugin not working

You can avoid to declare that player is a dependency for your javascript file, the problem is that Jquery isn’t recognized. Change this line: wp_enqueue_script( ‘main’, plugins_url( ‘/main.js’ , __FILE__ ),array(“jquery”,”player”),’0.0.3′,true); into this: wp_enqueue_script( ‘main’, plugins_url( ‘/main.js’ , __FILE__ ), [“jquery”] ); Also avoid to enqueue your script in the footer.

Get term count on a category page

Rather than adding shortcode you have to add the hook which is on the product category page: // Use this hook for working directly on category page // add_action( ‘woocommerce_archive_description’, ‘show_category_product_counts’, 10 ); // Use this shortcode hook if you want to put on anywhere in the category page if you are using Elementor/WPBakery add_shortcode( … Read more

How i make a shortcode from this code

To make the inteire file a shortcode its at least something to considered, for that I would call the page instead. However a short code can be done like this. paste it in your functions.php if (! function_exists(‘my_custom_shortcode_with_the_name_I_had_choosen’)) { function my_custom_shortcode_with_the_name_I_had_choosen(){ … your code …. } } add_shortcode(‘whatever_name’, ‘my_custom_shortcode_with_the_name_I_had_choosen’); to a few more information check … Read more

Why My slider shortcode display above header

You need to return the value from the output buffer, like this: //slider shortcode function slider_shortcode($atts) { extract( shortcode_atts( array( ‘id’ => ”), $atts)); $id = $id; ob_start();?> <div class=”gallary”> <?php // Check rows exists. if( have_rows(‘slider’,$id) ): // Loop through rows. while( have_rows(‘slider’,$id) ) : the_row(); $slider_image = get_sub_field(‘slider_image’); $slider_heading = get_sub_field(‘slider_heading’); $slider_text = … Read more

Shortcode attribute “title” doesn’t appear in $atts array

It appears that you are not extracting your $atts correctly or at all for that matter. Use the correct procedure to get access to the passed attributes allong with setting up defaults as a fallback: extract( shortcode_atts( array( ‘shortcode’ => ‘default_value’, ‘title’ => ‘Default Title’, ), $atts ) ); There is infact an extensive guideline … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)