There are 2 major bugs here
Problem 1: Your shortcode registration is invalid
You should be seeing lots of messages about this in your PHP error log
add_shortcode('splite', 'splite_article');
There is no function named splite_article
, there’s a class function but the code didn’t tell it to use it. So instead of calling your shortcode function, it generates a PHP error message and puts it in the log.
add_shortcode
expects a PHP callable value, so splite_article
is equivalent to splite_article()
, but you need $this->splite_article()
.
So instead use the appropriate callable [ $this, 'splite_article' ]
Problem 2: Shortcodes do not echo
echo $content;
That’s not how shortcodes work, shortcode callbacks do not echo HTML, they return it. This shortcode will be breaking a lot of things as a result of this.
Luckily the solution is simple, return
the shortcodes content instead.