Pass variables from one widget to another widget

You don’t need to make it global. If your include a file from within a functions scope, any variables that you defined in that function (before that point) will be exposed in the included file as well. But because the variable you are talking about represents the state of the footer file inclusion (if I … Read more

Multisite Global Custom Posts

In case anyone comes across this question in the future, I found a plugin that does everything I want. The plugin is Multisite Post Duplicator which is a free plugin available in the WordPress plugin directory. Below are some of the plugin features. Features: Copies all custom fields Copies all related post meta Includes any … Read more

store custom WP table names in a global variable

The DB_ constant prefix in WordPress is generally considered reserved for DB_NAME, DB_HOST, DB_USER and DB_PASS. Using it for plugin-specific constants is, in my opinion, not a great idea. The only implication it might pose is if other plugins try to use the constants, but that’s purely theoretical. The proper way to do this is … Read more

JavaScript, best way to use data from the loop

You can use WP_Query to get almost any post data out of your WordPress install. $sub_pages = new WP_Query( array( ‘post_parent’ => 3, ‘post_type’ => ‘page’ ) ); print_r($sub_pages->posts); This would get you the following: Array ( [0] => WP_Post Object ( [ID] => 94 [post_author] => 1 [post_date] => 2015-08-20 11:19:27 [post_date_gmt] => 2015-08-20 … Read more

What is the global $wp object used for?

It contains the main instance of the WP class, which is primarily responsible for parsing the request URL and querying the appropriate posts, as well as sending headers and handling 404s. It can be used for things like getting the current request URL. If it’s declared in a function but not used, it’s likely a … Read more

How to check if this is the nth instance of a given shortcode in a post

If you’re using a class, it would be class MyShortcode { static $instance = 0; function __construct($args = array()) { add_action( ‘init’, array(&$this, ‘init’) ); } function init() { add_shortcode(‘myshortcode’, array(&$this, ‘shortcode’)); } static function shortcode($atts) { //this is the code of your shortcode // you can increment your counter self::$instance++; } }

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