OOP – add_action
OOP – add_action
OOP – add_action
That happens, because you run the function in add_shortcode(). To send is as callback, use: add_shortcode(‘examp_code’, array ( $obj, ‘ex_funct’ ) ); Now you have still a problem: you create output in your shortcode callback. Never do that, you have to return a string. Change it to: function ex_funct(){ return ‘<h3>Hello</h3>’; }
Property value of null when value is assigned inside a method hooked to the wp action hook
Autoloading a PHP class – working outside, but not inside WordPress plugin
That’s a very good question. It goes down to the dark heart of the plugin API and best programming practices. For the following answer I created a simple plugin to illustrate the problem with easy to read code. <?php # -*- coding: utf-8 -*- /* Plugin Name: Anonymous OOP Action */ if ( ! class_exists( … Read more
calling a function from a class in your template
Creating a register settings class that supports extended classes
Object oriented programming, add_action in constructor not firing
Ok i was a bit headblocked; with the following snippet i was able to get things working as expected: $media = abc_attachments( $post->ID ); $arrayofids = array(); foreach( $media as $key ) { array_push($arrayofids, $key->ID); } preprint($arrayofids); Which lead to the following output: Array ( [0] => 1072 [1] => 1067 )
Best way to access variables in template markup