Get shortcode attribute value to another function

<?php class MakeShortcode { public $color; public function __construct() { add_action( ‘init’, array($this, ‘PostBLock’) ); add_shortcode( ‘PostBLock’, array($this, ‘getpostblock’) ); add_action( ‘wp_enqueue_scripts’, array( $this, ‘inlinestyle’) ); } public function getpostblock( $atts ){ extract( shortcode_atts( array( ‘section_color’ => ‘#000000’, ), $atts) ); return $section_color; } public function inlinestyle(){ $color = $this->getpostblock(); wp_enqueue_style( ‘custom-style’, get_template_directory_uri() . ‘/css/style.css’ … Read more

pages shortcode filtering by category

ob_start() This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer. ob_get_clean() Gets the current buffer contents and delete current output buffer. try this code function qut_research_subpages_shortcode_frontend($atts) { $args = array( ‘post_type’ => ‘page’, … Read more

Impossible to display modification in shortcode code?

I’m pretty sure it’s this line: $this->function = static::className().’::getCallBack’; I believe this is going to be the name of the abstract class. You may want to try get_called_class() or something similar. Try logging the $this->function to see what the name of the class is.

Need to Echo A Url path to show on a wordpress page

You can find that with somthing like the following add_shortcode( ‘url_path_number’, function ( $atts ) { // use an attribute or the current URL $a = shortcode_atts( array( ‘url’ => get_permalink(), ), $atts ); // get the path from the URL $path = parse_url($a[‘url’],PHP_URL_PATH); $parts = array_filter(explode(“https://wordpress.stackexchange.com/”, $path),function($v) { return $v !== ”; }); // … Read more