How to filter custom taxonomy term name, slug, and description?

The default fields name, slug and description are not term metadata, so you should instead use wp_update_term() to update those fields. So just replace those three add_term_meta() with: wp_update_term( $term_id, ‘codes’, [ ‘name’ => $name, ‘slug’ => $slug, ‘description’ => $desc, ] ); Additionally, instead of using $_POST, I would use get_term() to get the … Read more

php esc_html_e with an html link inside not working

The point of esc_html is to ensure that the end result is plaintext, no HTML tags or scripts etc, just plaintext. The __ part passes it through the localisation API, and the e indicates it will echo on its own. So what you are seeing is expected and normal. Instead, you will need to make … Read more

I have a snippet to redirect all users to a maintenance page. How do I exclude users with admin role?

I would advise againt using anonymous functions for callback (when ever you can) as you can’t use a targeted remove_action on it. What Maythan8 answered will work but it can be done with fewer functions. add_action(‘template_redirect’, ‘bt_maintenance_redirect’); function bt_maintenance_redirect () { if (is_page(4848) || current_user_can(‘administrator’)) return; if (wp_safe_redirect(esc_url(home_url(‘maintenance/’)))) exit; } You used esc_url_raw but this … Read more

set post limit at load more ajax wordpress

Something v basic might look like this var ppp = 9; var loaded = ppp; var maxPosts = 50; postData.append( ‘action’, ‘loadmore’ ); postData.append( ‘paged’, section_posts ); postData.append( ‘posts_per_page’, ppp ); if ( loaded < maxPosts ) { // check if we’re below the max post number const xhr = new XMLHttpRequest(); xhr.open( ‘POST’, ajaxurl … Read more

Can’t retrieve element with WordPress default @fetch_rss();

I suggest you to use fetch_feed() instead. Example: $rss_feed = fetch_feed( ‘https://canpl.ca/feed/rss2/’ ); if ( ! is_wp_error( $rss_feed ) ) { echo ‘<ul>’; foreach ( $rss_feed->get_items( 0, 5 ) as $item ) { $enclosure = $item->get_enclosure(); $enc_url = $enclosure ? $enclosure->get_link() : ‘No enclosure found’; echo ‘<li>’ . $item->get_title() . “<br>Enclosure URL: $enc_url</li>”; } echo … Read more