the_excerpt() does not work with has_excerpt()?

excerpt_length is only applied to generated excerpts— excerpts automatically generated from the post body. To trim your manually created excerpt, use the same function that trims the generated one— wp_trim_words. if(has_excerpt()) { $length = apply_filters(‘excerpt_length’,20); echo wp_trim_words(get_the_excerpt(),$length); } else { the_content(); }

Loading a sidebar on an Ajax call

is_admin() returns true if you’re doing an Ajax request. So this is why my code didn’t work. Instead I’ve done this: add_filter( ‘loop_start’, ‘my_sidebar_widget’, 25 ); function my_sidebar_widget() { if ( is_active_sidebar( ‘my_sidebar’ ) && (defined( ‘DOING_AJAX’ ) && DOING_AJAX ) || !is_admin() ) { echo ‘<div id=”my_sidebar”>’; dynamic_sidebar(‘my_sidebar’); echo ‘</div>’; } } defined( ‘DOING_AJAX’ … Read more

Is this correct usage of filters in WordPress [closed]

Umm. Normally, people ask questions here that are more than yes/no questions, but hey, I’m game. Yes, that code looks fine to me. Hope that helps! 🙂 Also note that there is a built in function called __return_true which is there for usage just like so: add_filter( ‘image_priority’, ‘__return_true’ ); Easy. Also also note that … Read more

Updating User Profile on Registration

Try dumping your data and you should see the problem: function coinDeposit() { $current_user = wp_get_current_user(); var_dump($current_user); die; update_user_meta( $ID, ‘depositAddress’, $account); } The user object is empty. That is because a newly created user is not automatically logged in. There is an email confirmation step, and then login. Until that login, wp_current_user() isn’t going … Read more

wp_get_attachment_link filter not working

Have you tried using the ‘the_content’ filter? Something like this should probably do the Job , note that i have not had the time to test this . function my_prettyadd($content) { global $post; $pattern = “/(<a(?![^>]*?rel=[‘\”]prettyPhoto.*)[^>]*?href=[‘\”][^’\”]+?\.(?:bmp|gif|jpg|jpeg|png)[‘\”][^\>]*)>/i”; $replacement=”$1 rel=”prettyPhoto[“.$post->ID.’]”>’; $content = preg_replace($pattern, $replacement, $content); return $content; } add_filter(“the_content”,”my_prettyadd”); simple regex that will add a rel to … Read more

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