is it possible to run some php code within a wordpress page?

You can create a simple plugin and either add a shortcode to run your php, or filter the_content and add a conditional check for your specific page and inject your DB output. This way your code will be independent of the theme and more portable. Use the wpdb class to query any database /table.

Allow only 1 taxonomy per custom post type [duplicate]

Here’s the JS I use to replace checkboxes for radio buttons. function checktoradio(){ echo ‘<script type=”text/javascript”>jQuery(“#categorychecklist-pop input, #categorychecklist input, .cat-checklist input”).each(function(){this.type=”radio”});</script>’; } add_action(‘admin_footer’, ‘checktoradio’); This would also work for custom terms, you just need to find out the custom term ID used by inspecting the metabox element. You would place this code inside functions.php. It … Read more

Autoloading in Child Theme

So there are one or two things to keep in mind: There should only be 1 vendor folder There should be a primary composer.json that’s in your project root, that would pull in all the dependencies You always check for and load the autoloader in the current directory, there’s no guarantee it is or isn’t … Read more

How can I call WordPress core functions in external scripts?

I get the solution. To call functions from WordPress from a custom script, you need to import wp-load: require_once(“/path/wp-load.php”); Thats all, I can work fine with those functions. I save my own script in the root of my PHP WordPress and I didn’t need a plugin.

List of all theme customizer control types?

Have a look in the source: http://core.trac.wordpress.org/browser/trunk/wp-includes/class-wp-customize-control.php Basic control types: text checkbox radio select dropdown-pages Also some advanced control types (as-described by Otto): WP_Customize_Color_Control – extends the built in WP_Customize_Control class. It adds the color wheel jazz to places where color selection is needed. WP_Customize_Upload_Control – This gives you an upload box, for allowing file … Read more

WordPress Warning: preg_replace(): JIT compilation failed: no more memory

I added the following line to the php.ini and restarted Apache and it worked (Xampp on macOS): pcre.jit=0 This disables PCRE’s just-in-time compilation. Further information: http://php.net/manual/en/pcre.configuration.php#ini.pcre.jit If you can’t find the location of php.ini and are using Xampp, go to localhost and select the PHP information link and it is displayed there.

Confirmation box when submitting post for review

A useful fast way is to use JavaScript in combination with an Ajax action that outputs the box. Create a small plugin. Create a folder inside plugins directory, naming it ‘SubmitReviewConf’. In this folder create a PHP file named SubmitReviewConf.php. In this file, put this code: <?php /** * Plugin Name: Submit for Review Confirmation … Read more

Is it safe to use $_SERVER[‘REQUEST_URI’]?

$_SERVER[‘REQUEST_URI’] will not be empty in WordPress, because it is filled in wp_fix_server_vars() (file wp-includes/load.php). This function is called in wp-settings.php before any plugin is loaded. So you can use it. But always escape the value. It is global and can be changed by any other code, so you cannot trust its value. A different … Read more