Using $this from child class inside shortcode function

Your issue is in the callable object you add: array( __CLASS__, “build_shortcode”) This translates to: array( “WC_Product_Categories”, “build_shortcode”) Which is equivalent to: WC_Product_Categories::build_shortcode(); But build_shortcode is not a static function/method, and static functions/methods do not have a $this object, because there is no object associated. What you actually want is: array( $this, ‘build_shortcode’ ) Which … Read more

Page code showing in WP Dashboard

Shortcodes should not echo any output. They should always return the text that is to be used to replace the shortcode. You either write the html code on a variable: function my_shortcode() { $output=”<div>something</div>”; return $output; } Or you can use php output buffering: function my_shortcode() { ob_start(); ?> <div>something</div> <?php return ob_get_clean(); } In … Read more

Code is providing a row of data but not formatting it as table

It’s not displayed as table, because you don’t return correct HTML code. Let’s take a look at your code (I’ve put comments at end of incorrect lines): $content=”<table>”; $content .= ‘</tr><th>Week Beginning</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th><th>Sunday</th><th>Weekly Total</th><th>Previous Week Totals</th></tr>’; // <- here you open TR with </tr>, so it’s already incorrect $results = $seconddb->get_results( ‘ SELECT * FROM seconddb_PontoonBoats_LineOne_2Log’ … Read more

Just display content between shortcode brackets

I have good news: the answer is simple. The WordPress Codex concerning Enclosing Shortcodes (like the one you posted here) shows that the shortcode callback has 2 arguments, $atts and $content. You want to work with $content: function wporg_shortcode($atts = [], $content = null) { // do something to $content // always return return $content; … Read more

Image Shortcode from ACF ID

It’s because you have forgot to use $atts[‘post_id’] please find below code. function acf_featured_item_shortcode( $atts ) { // Attributes $atts = shortcode_atts( array( ‘post_id’ => ”, ), $atts ); $post_id = $atts[‘post_id’]; $image = get_field(‘featured_item’, $post_id ); $size=”medium”; // (thumbnail, medium, large, full or custom size) if( $image ) { $output = wp_get_attachment_image( $image, $size, … Read more

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