Run Python Script on WordPress Website

This issue of permission denied is resolved.. Permission was already given but I have added ‘env python’ in the popen function.. Now the code is running as expected.. add_shortcode( ‘run_test_py’, ‘test_py’ ); function test_py( $attributes ) { $data = shortcode_atts( [ ‘file’ => ‘test.py’ ], $attributes ); $handle = popen(‘env python ‘. __DIR__ . “https://wordpress.stackexchange.com/” … Read more

Change My Basket text in the header of WooCommerce Artificer theme

The functions are defined in the includes folder of the artificer theme, in the theme-woocommerce.php file: // Add the cart link to the header add_action(‘woo_nav_before’, ‘artificer_header_cart_link’, 20); if ( ! function_exists( ‘artificer_header_cart_link’ ) ) { function artificer_header_cart_link() { if ( class_exists( ‘woocommerce’ ) ) { echo woocommerce_cart_link(); } } } // Add the checkout link … Read more

Manually Removing Plugins

Addition to @PatJ answer: Keep in mind that an uninstall/deactivation functions won’t trigger. So in case the plugin(s) in question leave back a lot of DB entries, you’ll have to manually clean up the DB. Another option would (maybe) be to use WP CLI and try to manually trigger any uninstall functions. This will only … Read more

Woocommerce exclude specific category products from related products [closed]

Old question, but ranks high in Google. Here’s a solution that works with today’s Woocommerce. Add this to your functions.php or custom plugin. function exclude_brands_from_related( $categories ){ // array of category id’s that should be excluded $exclude_cats = array( ‘100’, ‘101’, ‘102’); foreach( $categories as $index => $cat ){ if( in_array( $cat->term_id, $exclude_cats ) ){ … Read more

Get category ID in “archive-product.php”

Normally this should work with get_queried_object_id(). Anyway, as I don’t know what Woo exactly does to the query, this can be as well wrong, as the API function references to the object that is currently queried. And this is the object from the last query. So you might also do the following: Disclaimer: The below … Read more

How can I include PHP-Code to my post?

You can edit the single.php and/or content-single.php files in your theme. Then it depends what you mean by “some”. You could apply some conditions to your code (only certain categories, certain tags, certain specific post IDs only, etc.) You could also create a custom post type “myspecialposts” and create single-myspecialposts.php (codex)