the_title filter applying to menu items

Use in_the_loop() conditional tag to make sure you are modifying the title inside the Loop and to prevent the hook changing titles somewhere else: function customize_wishlist_title( $title ){ $current_user = wp_get_current_user(); $loggeduser = $current_user->user_login; // give attention to the following condition: if ( is_page( 258 ) && in_the_loop() ) { $title=”<span class=”username”>”.$loggeduser.’\’s’.'</span>’.’&nbsp;’.'<span>Wishlist</span>’; } return $title; … Read more

add_theme_support( ‘title-tag’ ) in conflict with custom titles function

Your problem is that you can not use wp_title() in the theme if the theme already supports title-tag. The <head> of your theme should look like this: <head> <meta charset=”<?php bloginfo( ‘charset’ ); ?>”> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <?php wp_head(); ?> </head> The filter and title-tag support: add_action( ‘after_setup_theme’, ‘theme_functions’ ); function theme_functions() { add_theme_support( … Read more

Bulk edit wordpress images alt and title attributes

You can use the ‘wp_get_attachment_image_attributes’ hook add_filter( ‘wp_get_attachment_image_attributes’, ‘image_attributes’, 20, 2 ); function image_attributes( $attr, $attachment ) { // Get post parent $parent = get_post_field( ‘post_parent’, $attachment ); // Get post title $title = get_post_field( ‘post_title’, $parent ); if ( is_single( $parent ) ) { $attr[‘alt’]=$title; } return $attr; } Or Check Out my new … Read more

Custom Taxonomies Terms as Post Title for Custom Post Types upon Publishing

I’ve pieced together a solution. Let me know if it’s what you need: add_filter(‘the_title’,’term_filter’,10,2); function term_filter($title, $post) { $post = get_post($post) ; if($post->post_type === ‘special_post_type’) { $terms = wp_get_object_terms($post->ID, ‘taxonomy’); if(!is_wp_error($terms) && !empty($terms)) { $title = $terms[0]->name; } } return $title; } Basically, I’m using a filter for the title that checks what post type … Read more

What hook is executed just after wp_query has been executed?

Yep you’re right template_redirect is fired right after wp which performs the query. A very useful plugin you might want to look at is: https://wordpress.org/plugins/query-monitor/ This can help you to see what’s loaded on a particular page during development, in addition to what hook is used

What is the use of $page_title and how to use it?

Ok my bad found the answer on the codex page but at the very bottom so I’m adding this here as well so if anyone like my didn’t catch it on WordPress’s codex, they can find it here 🙂 Just use get_admin_page_title(); See the example 1 below: function register_my_custom_submenu_page() { add_submenu_page( ‘tools.php’, ‘My Custom Submenu … Read more

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