Creating a non-hierarchical Taxonomy that behaves like categories

This blog post by “Gazchap” deals with exactly the situation you are, and they updated it after publishing to your follow-up problem: Fortunately, version 4.4 of WordPress introduced a filter – post_edit_category_parent_dropdown_args – that could be used to control the parent terms shown in these meta boxes. It’s designed to let the developer change the … Read more

get_post_types() can’t get some of my post type

Build in WordPress function for fetching all registered post types: get_post_types() <?php // hook into init late, so everything is registered // you can also use get_post_types where ever. Any time after init is usually fine. add_action( ‘init’, ‘wpse34410_init’, 0, 99 ); function wpse34410_init() { $types = get_post_types( [], ‘objects’ ); foreach ( $types as … Read more

PHP -> SQL Query with Summing

Looking at this, I see that “Paid”, a string, isn’t in quotes. That would cause an error. You can add $wpdb->show_errors() and $wpdb->print_error() methods to reveal that, and any other mysql issues. Also when querying the database, you should use the $wpdb->prepare() method to escape and prepare your variables for query (yes $user->ID probably can’t … Read more

Redirect a WP created page to a manually created PHP file inside theme folder

Maybe you can use query_vars filter and parse_request action. add_action(‘init’, ‘initInternalWPRewrite’, 10); // Add your rewrite rule, you don’t need to create a wordpress page function initInternalWPRewrite () { add_rewrite_rule(‘^diagnostics/?$’, ‘index.php?diagnostics=1’, ‘top’); } add_action(‘init’, ‘rewriteRulesCacheInit’, 10); // This method is useful to avoid manual flush rewrite cache function rewriteRulesCacheInit () { if (!get_option(‘rewrite_rules_cache’)) { add_option(‘rewrite_rules_cache’, … Read more

How to use mysql LIKE with wpdb?

According to the Codex, the delete method will not accept the LIKE operator. You’ll be better off just using the query method. $query = $wpdb->prepare(“DELETE FROM $wpdb->posts WHERE post_type=”flamingo_inbound” AND post_content LIKE %s”, ‘%’.$mail.’%’); $wpdb->query($query); Hopefully $mail doesn’t have a % or _ character otherwise you need to escape it before you build $querylike so: … Read more

Change page password every day (predictable password ;) )

It need not be very complicated. You can simply create a pattern like 2018-09-07-ABC (suffix of ABC) for the date 2018-09-07. Set up the password creation/validation logic like password = md5(‘2018-09-07-ABC’). An administrator if they know the pattern, they can anytime goto any online md5 utility such as http://www.md5.cz and enter the pattern for current … Read more