Checked() showing up twice in custom fields

checked() will echo the result by default. That’s the problem. To concat, you need to disable echo functionality by specify third param to false: echo ‘<input type=”checkbox” id=”my_meta_box_check1″ name=”my_meta_box_check1″ ‘ . checked( $check, “on”, false ) . ‘/>’;

Hide the Private prefix on one specific page

This worked for me. One of the keys is that you have to make sure to pass the content through unchanged if it doesn’t meet the condition. function title_format($content) { if (is_page(‘members’)) : return ‘%s’; else : return $content; endif; } add_filter(‘private_title_format’, ‘title_format’); add_filter(‘protected_title_format’, ‘title_format’); This will only apply to the page with a slug … Read more

How to add a column to the Trash page?

You can check the value of the post_status query variable and make sure that it’s set to trash: function wpse239286_trash_column( $columns ) { // Bail if we’re not looking at trash. $status = get_query_var( ‘post_status’ ); if ( ‘trash’ !== $status ) { return $columns; } return array_merge( $columns, array( ‘trash_column’ => __( ‘Trash Column’, … Read more

Automatically Add Specified Value to Attachment Metadata upon Upload

You’re close! Try using these hooks instead. // Add post meta to new audio uploads. function auto_update_audio_meta( $post_ID ) { if ( wp_attachment_is( ‘audio’, $post_ID ) ) { add_post_meta( $post_ID, ‘artist’, ‘test’ ); } } add_action( ‘add_attachment’, ‘auto_update_audio_meta’ ); For attachment updates // Update post meta to updated audio uploads. function auto_update_audio_meta( $post_ID, $post_after, $post_before … Read more

Custom excerpt legnths for specific pages

The excerpt length is the number of words, not the characters. Assuming that every word is 8 characters long in average, you might want to use this: function wpdocs_custom_excerpt_length( $length ) { if( is_front_page() ){ return 50; } else { return 100; } } add_filter( ‘excerpt_length’, ‘wpdocs_custom_excerpt_length’, 999 ); Source : WordPress codex

How to make unique add_filter to the_content of specific page template files – so each template gets its own addition

You can get the name from the global $template. I don’t know of a way to get it with an API call instead of a global, but such is life. function floridacontent( $content ){ global $template; $name = basename( $template, ‘.php’ ); if( ‘page-florida’ == $name ){ $content .= ‘Forida added content’; } return $content; … Read more

Query children and parent title

I’m not entirely sure if I get your problem correctly, because of the “it’s not an option part”, but… You get children pages of page with ID = 2, so it looks like you want to display the title of that page. If so, then this code will solve your problem: <?php $args = array( … Read more

Display a text message if the shortcode is found?

Try this: <article> <div class=”entry-content”> <?php $current_user = wp_get_current_user(); if ( isset( $current_user->user_email ) ) { echo ‘<p>’ . sprintf( __( ‘%s, here is your client area’, ‘my-theme’ ), $current_user->display_name ) . ‘:</p>’; $output = do_shortcode( ‘[picu_list_collections email=”‘ . $current_user->user_email . ‘”]’ ); // the shortcode returns an empty <ul> tag, if there is no … Read more