custom shortcode will not display the wrapped content

Because the shortcode must return a string. Avoid using the “echo” function in shortcode. Instead of doing that: function my_shortcode_function($content){ echo ‘<div class=”wrap”>’; echo ‘<div class=”col”>’.$content.'</div>’; echo ‘</div>’; } Do that: function my_shortcode_function($content){ $shortcode_return = ‘<div class=”wrap”>’; $shortcode_return .= ‘<div class=”col”>’.$content.'</div>’; $shortcode_return .= ‘</div>’; return $shortcode_return; } Or use object buffering: function my_shortcode_function($content){ ob_start(); ?> … Read more

Add htaccess rules with insert_with_markers at beginning of htaccess

Using insert_with_markers() function you can insert your rules only between WordPress comments e.i. # BEGIN WordPress and # END WordPress. So, you should use plain PHP to achieve your aim. Create your rules Read existing .htaccess and concatenate your and existing rules Write the file Here is a dirty example: <?php $str = “# BEGIN TEST\n# MY RULES\n# END TEST\n”; … Read more

Shortcode Inside Class Not Working

if you use any hooks, filters or shortcodes with class methods, you have three options. either declare it in the context of an instance, in which case, you can refer to the instance of the class. class myClass { function __construct() { add_shortcode(‘my_shortcode_name’, [ $this, ‘shortcode’ ]); } function shortcode() { //your code here //properties … Read more

wp_insert_post not working

I guess the reason is you have not added post title and added post id $my_post = array( ‘post_id’ => 1, ‘post_status’ => ‘pending’, ‘post_type’ => ‘post’ ); Ideally if should be $my_post = array( ‘post_title’ => wp_strip_all_tags( $_POST[‘post_title’] ), ‘post_content’ => $_POST[‘post_content’], ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_category’ => array( 8,39 ), ‘post_type’ … Read more

Slide in Panel WordPress Post

The reason why your query fails is the following. You are finishing the loop before your cd-panel with <?php endwhile; wp_reset_postdata(); ?> which is correct. However, after that you are simply using <?php the_title(); ?>, <?php the_content(); ?> which is just a single template tag, and in your case, outputs the title of the first … Read more

Force SSL using FORCE_SSL_ADMIN

If you are using docker-compose and the WORDPRESS_EXTRA_CONFIG as I was, when I stumbled across that error, the solution would be to use double-dollar-sign notation as described in a corresponding issue in the docker-compose repo on GitHub. This additional environment variable is described in the “How to use this image” of the official image documentation … Read more

Asking popup for delete post in WordPress [closed]

Yes, it’s possible. You have to create a JavaScript File and enqueue this file for admin use. This hook is to add files for the backend: add_action( ‘admin_enqueue_scripts’, ‘your_function_name’ ); This hook is to add files for the frontend: add_action( ‘wp_enqueue_scripts’, ‘your_function_name’ ); So we need to use the admin_enqueue_scripts hook and create our function: … Read more