is_singular() in mu-plugins not working

When the active_plugins option is retrieved, WordPress does not yet know what page has been requested, so this approach will not work. In order to achieve your objective, you would selectively activate the plugin (rather than selectively deactivate the plugin), but this may cause problems and destabilize your site (untested): add_filter( ‘option_active_plugins’, static function ( … Read more

Show category name in category.php when posts assigned to multiple categories

For the heading on a category archive use either: the_archive_title(); Or: single_term_title(); The first one can be used on the template for any archive, while the second should only be used on category, tag, or taxonomy archive templates. You shouldn’t need to get anything from any of the individual posts. They may have other categories … Read more

Change Pages to Post in Woocommerce without Plugin

To change the WooCommerce order pages back to posts without using a plugin, you can modify the post type of WooCommerce orders in WordPress. This can be achieved by adding custom code to your theme’s functions.php file or creating a custom plugin. Here are the steps to do this: Access Your WordPress Files: You can … Read more

Server 500 error when updating post using block editor

Based on the error logs and the behavior you’ve described, the issue with the WordPress post not updating properly and causing a 500 internal server error seems to be related to a function in your theme or a plugin that is interacting with the content, particularly images. Here’s a breakdown of what the logs suggest … Read more

How to get a list of all posts and their categories?

If you want to export the data to a CSV or JSON file directly from the SQL query, you can use the MySQL INTO OUTFILE clause. SELECT wpd9_posts.post_title, GROUP_CONCAT(wpd9_terms.name) AS categories FROM wpd9_posts LEFT JOIN wpd9_term_relationships ON (wpd9_posts.ID = wpd9_term_relationships.object_id) LEFT JOIN wpd9_term_taxonomy ON (wpd9_term_relationships.term_taxonomy_id = wpd9_term_taxonomy.term_taxonomy_id) LEFT JOIN wpd9_terms ON (wpd9_term_taxonomy.term_id = wpd9_terms.term_id) WHERE … Read more

Fatal error: $post is null?

I’ve fixed the problem now. I got hold of my old database dump file from the old server. The reason the indexes weren’t added is because the sql contained rows like: CREATE ALGORITHM=UNDEFINED DEFINER=`xxxxxxxx`@`localhost` SQL SECURITY DEFINER VIEW `wp_ …which was not getting executed due to insufficient user permissions. This meant the consequent indexing lines … Read more

Modify Post URL Programmatically

When you are using wp_insert_post() there is a param post_name. If you do not pass it then it will sanitise your post title and update. You only have control to add post_name but the full URL is created based on your Permalink settings.

Global $post value outside the loop

Yes, this is how it is supposed to work. The global $post variable is set quite early in the page load, at the wp hook. As you can see from the hook order, this is before the loop starts. Basically the $post object exists independent from its actual content in the database, which you retrieve … Read more