Meta box not saving spaces

The answer is simple: do not use sanitize_html_class. Take the input as it is (you can still do basic validation like length, making sure it is an integer only etc) and if you need to output that on the front and you don’t trust the user who stored the data either use something like esc_html … Read more

How to get the first letter from custom field?

Try this…. <?php $string = get_field(‘first_name’); echo $string[0]; ?> I am not that much familiar with ACF. But my answer is based on their function reference here http://www.advancedcustomfields.com/resources/the_field/ Hope this helps. Sabbir H

php if, else & custom fields – syntax error

There are a couple of ways to do it. Try: <?php if ( get_post_meta($post->ID, ‘author-photo’, ‘author-name’, ‘author-bio’, true) ) { ?> <div class=”authorbox”> <div class=”authorphoto”> <img src=”https://wordpress.stackexchange.com/questions/200118/<?php $key=”author-photo”; echo get_post_meta($post->ID, $key, true); ?>” /> </div> <div class=”authorbox-content”> <h3 class=”author-name”><?php $key=”author-name”; echo get_post_meta($post->ID, $key, true); ?></h3> <p><?php $key=”author-bio”; echo get_post_meta($post->ID, $key, true); ?></p> </div> </div> <?php … Read more

Redirecting to an external URL

Use is_user_logged_in() to show link only or logged in users. And use the_author_meta() to get url to google drive. Like this inside The Loop: <?php if(is_user_logged_in()): ?> <a href=”https://wordpress.stackexchange.com/questions/201838/<?php the_author_meta(“google_drive_url’) ?>”>Click to open Google Drive</a> <?php endif; ?>

Append custom field items to content from plugin

You can use the the_content filter to add code directly into the content. add_filter( ‘the_content’, ‘wpse_202010_modify_the_content’ ); function wpse_202010_modify_the_content( $content ) { global $post; if ( in_array( $post->post_type, array( ‘post’, ‘page’ ) ) ) { $content=”<p>New content here</p>” . $content; } return $content; }