Add meta noindex to post if it has a specific taxonomy

You can use the wp_robots filter to manipulate the robots meta tag as needed. And as you’re checking against a taxonomy term you can use the has_term() helper conditional to make your code look a litte nicer. (A post can be passed to has_term() as the 3rd parameter, but if it is not passed then … Read more

search and replace preword from author

This code is my answer: <a href=”<?php echo get_author_posts_url( get_the_author_meta(‘ID’), get_the_author_meta( ‘user_nicename’ ) ); ?>” class=”m-article-author”> <?php $author_bio_avatar_size = apply_filters( ‘tierisch_wohnen_author_bio_avatar_size’, 49 ); echo get_avatar( get_the_author_meta( ‘user_email’ ), $author_bio_avatar_size ); ?> <?php if (get_the_author_meta(‘display_name’) === ‘xxx Team’) { echo”The”; } else { echo”From”; } ?> <span class=”m-article-author-name”><?php the_author(); ?></span> </a>

WordPress: get recent posts, delete the current category

Assuming you are using custom query to fetch the latest posts from other categories. In that case, you don’t need to hook into pre_get_posts as the category__not_in parameter can be passed directly into the query arguments. //Get the current category ID $catID = get_queried_object_id(); //Pass it to the Query arguments $args = array( //Your other … Read more

Add_action not working in required file of functions.php

Of course there can be many reasons, but if you require ajax.php in functions.php above the hook with wp_enqueue_script( ‘myJSScript’ …); – it will not work. wp_localize_script() Works only if the script has already been added. function theme_enqueue_ajax(){ //try to add wp_enqueue_script( ‘myJSScript’ …); here wp_localize_script( ‘myJSScript’, ‘ajaxUrl’, array( ‘url’ => admin_url( ‘admin-ajax.php’ ) ) … Read more

PHP 8, AJAX mail form to function.php doesn’t work

This is the cause of your problem: function true_add_ajaxform(){ … function set_html_content_type() { return ‘text/html’; } } You shouldn’t nest function definitions! Move it out of the function like this: function true_add_ajaxform(){ … } function set_html_content_type() { return ‘text/html’; }