Call to undefined function issue

I know there are other, maybe better ways to do what I want to achieve, but I have to use this solution. I have two stylesheets: style.css – normal stylesheet style-dynamic.php – dynamic stylesheet linked to the first one I’m using some PHP code in the second one, like: #body { background-color: <?php echo get_option(‘theme_background’); … Read more

How do you load WordPress from an external script when using MultiSite? [duplicate]

This question already has answers here: Closed 9 years ago. Possible Duplicate: Using WordPress functions on other sites I have an external script that needs to load up WordPress in order to have access to WordPress functionality. In the past I have successfully done this by including wp-load.php. However, when using MultiSite, this does not … Read more

How to avoid wp-load.php within a PHP/CSS file?

This is tricky, as people usually mix wp-load with AJAX and I can’t really find a proper answer. Case 1 I have a dynamic style.php file that looks like this: <?php header(“Content-type: text/css”); require_once(‘../../../../wp-load.php’); ?> body { background: <?php echo get_option(‘background_color’); ?>; } Case 2 I’m using AJAX call:‘<?php bloginfo(‘template_directory’); ?>/framework/foo.php’,{ foo: smth, bar: … Read more

wp_enqueue_style with style.php and WordPress functions

I use wp_enqueue_style to add my stylesheet, like this: <?php wp_enqueue_style( ‘theme-style’, get_template_directory_uri() . ‘/style.php’, false, ‘1.0’, ‘all’ ); ?> It works fine BUT I need to run a WordPress function in the style.php file. The stylesheet file does not know that the core exists. This is what I’ve heard It’s bad to include wp-load.php. … Read more

Get current user data from external PHP page

I have a PHP page at the same level as the template/theme on WordPress. I need to be able to get the current logged in user details from this page. I have tried this: require_once( $_SERVER[‘DOCUMENT_ROOT’] . ‘/wp-load.php’ ); global $current_user; $current_user = wp_get_current_user(); var_dump( $current_user ); But it’s returning nothing. 0 as user_id and … Read more

update_option not working in stand-alone PHP script

I have a standalone PHP script in my WordPress theme’s directory that I run once every hour through a cron job (or manually if needed). All other WordPress functions are working except the update_option() function. A simplified version of my script looks like this: require_once(‘/path/to/site/wp-load.php’); $value = my_function(); update_option(‘my_option’, $value); and in one of my … Read more

external wordpress pages using wp-blog-header

I am setting up a few sections of a website external to the core wordpress installation, but I still want to use the built in wpdb functions, and/or header files from wordpress. I follow the instructions outlined in wordpress, setting up my headers: <? require(‘../cms/wp-blog-header.php’); define(‘WP_USE_THEMES’, false); . . ?> Everything works great. I can … Read more