Get widget Title from widget id

You can get the widget name from the widget id with this: <?php global $wp_registered_widgets; $id = ‘recent-comments-1’; // example if ( isset($wp_registered_widgets[$id][‘name’]) ) { echo $wp_registered_widgets[$id][‘name’]; } ?>

How to sanitize post title with commas

Depending on how you are outputting the title, the answer is different. But there are two possibilities. By Using wp_title(); If your theme is using the wp_title(); function in its header.php file, you can use the wp_title filter. However, this function is being deprecated since 4.4. add_filter( ‘wp_title’, ‘filter_the_title’ ); function filter_the_title( $title ) { … Read more

Can not set custom title on some WordPress setups

This is most likely due to difference in your theme’s support. Some themes render the title by using the wp_title filter, some by using pre_get_document_title. If your theme has this line in its functions.php file: add_theme_support(‘title-tag’); Then you need to use the pre_get_document_title filter, as follows: add_filter(‘pre_get_document_title’, ‘my_title’); function my_title() { return ‘Some title’; } … Read more

CPT Post Title Permalink: Replace “@” (or all special characters) with dash “-” instead of just removing

Just make sure your filter runs before the one that WordPress itself applies – add a priority of 9: add_filter( ‘sanitize_title’, function( $title ) { if ( FALSE !== strpos( $title, ‘@’ ) ) { $title = str_replace( ‘@’, ‘-‘, $title ); } return $title; }, 9 ); Usage: echo sanitize_title( ‘[email protected]’ ); Output: mytitle-example-org

How to retrieve category NAME instead of ID in a function with a taxonomy custom field?

You need to get the term object first. //Your meta field $post_custom_title = get_post_meta($post_id,’car_name’,true); //Get the term object by id. change taxonomy_slug to the taxonomy you intend to use $term = get_term_by( ‘id’, $post_custom_title, ‘taxonomy_slug’ ); //Retrive the term name and use it as post title $term_name = $term->name; //call the wp_update_post function setting $term_name … Read more

How to change page title (from a plugin) in twentytwentyone theme

You can do it like so: function filterDocumentTitle(string $title): string { // don’t change title on admin pages or when global $post is not loaded if (is_admin() || get_the_ID() === false) { return $title; } // don’t change title if shortcode is not present in content if (!has_shortcode(get_the_content(), ‘caption’)) { return $title; } return ‘special … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)