Execute wp_after_insert_post after the permalink is customized

To execute update_post_meta after the permalink is customized, you can use the save_post hook instead of wp_after_insert_post. Here’s how you can modify your code: add_action(‘save_post’, ‘add_permalink_to_new_post’, 10, 2); function add_permalink_to_new_post($post_id, $post) { // Check if this is a new post if ($post->post_date_gmt == $post->post_modified_gmt) { // Only run this on a newly created post update_post_meta($post_id, … Read more

Issue with WordPress Plugin Activation Hook and Table Creation

Not sure if this helps but try doing this in the main plugin file: require plugin_dir_path(__FILE__).’inc/plugin-setting.php’; require plugin_dir_path(__FILE__).’inc/db.php’; // Register activation hook in the main plugin file register_activation_hook(__FILE__, ‘wp_comment_reactions’); Move your function wp_comment_reactions to the db.php file and call it from the main plugin file.

YouTube embeds Cross-Origin Request Blocked (CORB) error

I have found out that i have enabled tracking protection in that particular Firefox profile. A relevant warning, which i oversaw by just displaying the errors, was also displayed. The resource at “https://googleads.g.doubleclick.net/pagead/id” was blocked because content blocking is enabled. Apparently https://googleads.g.doubleclick.net/pagead/id. does honor the tracking protection setting. Today i learned to use a clean … Read more

counting slugs not working?

Now I’m however getting: Fatal error: Uncaught Error: Undefined constant “cat” That’s because the cat and post_tag were not wrapped in quotes (e.g. ‘cat’), and they also did not start with the dollar sign ($) as in $cat, which indicates a variable, hence PHP tried to find the constants named cat or post_tag, and when … Read more

Creating an array with gettexed terms

To adapt the second part of your code to work with the first part, where you are using wp_dropdown_categories to generate the dropdown list, you can use the get_terms function to retrieve all terms of the tipologia taxonomy and then iterate over them to create your $names_trans array. In the wp_dropdown_categories call, you pass the … Read more

Count post with tags within one category?

Yes it is possible to count the posts with certain tags within a particular category. You can achieve this by using a combination of wp functions like WP_Query to retrieve posts and get_terms to retrieve the tags within the specified category. <?php $category_slug = ‘donotallowpost’; $term_slugs = [ ‘cat’, ‘bird’, ‘chinchilla’, ‘dog’, ‘ferret’, ‘hamster’, ‘horse’, … Read more

Advanced Custom Fields – How do I get field values of a group within a group field type

I should not have been looping at all. This (not optimized) code fixes all issues and adds Difficulty. add_shortcode(‘get_run’, ‘get_run_status’); function get_run_status($atts) { $atts = shortcode_atts(array( ‘run’ => ”, ), $atts); $run_output=””; $diff_output=””; $found_day = false; $found_night = false; $run_atts = sanitize_text_field($atts[‘run’]); $run_query = get_field($run_atts); if($run_query): $run_status = $run_query[‘status’]; $run_difficulty = $run_query[‘difficulty’]; endif; foreach ($run_status … Read more

Filtering according to the locale ‘de_DE’

To achieve filtering according to the locale de_DE for the taxonomy terms displayed in the search box selector, you can use a similar approach as your archive title filter. add_filter(‘wp_dropdown_categories’, function( $output, $args ) { $locale = get_locale(); if (‘de_DE’ == $locale && $args[‘taxonomy’] == ‘tipologia’) { // Modify output for German locale and ‘tipologia’ … Read more