post_exists returning 0 if title contain special characters

Looks like WP is using HTML entity encoding on the special characters, you need to parse the title using the html_entity_decode() function like so. $title = html_entity_decode(get_the_title($result->post_id)); if ( 0 === post_exists( $title ) ) { $title=”Document Id: “.$result->post_id .’ (Deleted)’; } I am not sure if the post exists function decodes the characters but … Read more

Wrong post title displayed from loop

Welcome the the WordPress Stack Exchange and congrats on your first post! First off, you may not want to use query_posts() here. Second off – the_post() needs to be before the_title() as it sets up all the posts functions such as the_title(), the_permalink() etc. and queues the next post in your while loop. Your Loop … Read more

Limit the Title Length on Custom Post Type Archive Page to a Set Number of Characters

<?php echo substr(get_the_title(), 0,42) ;?> Notice the echo and the get_the_title() This will get you the result you’re looking for. Here’s an alternative to consider: I’ve always found character limits cause weird word breaks that users find confusing. WordPress has a function called wp_trim_words that you can use. <?php echo wp_trim_words( get_the_title(), 5, ‘…’ ); … Read more

Replace text in the Title

First things first, lets clean up your code: <?php $wptitle = the_title(); $wptitle = str_replace(‘&’, ‘and’, $wptitle);?><?php echo $wptitle; ?> Lets remove the PHP tag spam and put things in nice clean lines: <?php $wptitle = the_title(); $wptitle = str_replace(‘&’, ‘and’, $wptitle); echo $wptitle; ?> Now if we look at the problem, the_title, that function … Read more

how i can add title to my featured image?

I’m not sure about your question, but the below code is more correct. $attr = array( ‘title’ => get_the_title(), ‘alt’ => ‘a nice view of the ocean’, ); echo sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/281220/%s”>%s</a>’, get_the_permalink(), get_the_post_thumbnail( null, ‘post-thumbnail’, $attr ) );

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