Show Post Thumbnail In Custom Post From Other CPT

If you want to get the post thumbnail URL, you can use get_the_post_thumbnail_url(): <?php $image_path=”images/club/” . $opposition->post_name . ‘.jpg’; // relative to the root directory if ( @file_exists( ABSPATH . $image_path ) ) { // Check the unique image first. $thumbnail = home_url( “https://wordpress.stackexchange.com/” . $image_path ); } elseif ( has_post_thumbnail( $opposition ) ) { … Read more

WordPress nl2br is not converting newline to html line break when saving metabox value

From the reference/description of sanitize_text_field(): Checks for invalid UTF-8, Converts single < characters to entities Strips all tags Removes line breaks, tabs, and extra whitespace Strips octets So a simple fix is, use sanitize_textarea_field(): The function is like sanitize_text_field(), but preserves new lines (\n) and other whitespace, which are legitimate input in textarea elements. // … Read more

Custom Post Type Display and works but But Blank Quick Edit

The issue looks to be associated with your mmd_member_track_columns_head() function. Instead of modifying the default columns, they are being completely overwritten, causing the Quick Edit functionality to stop working. In particular, the title key must be part of the array for it to work. Try something like this: add_filter(‘manage_mmdtrack_posts_columns’, ‘mmd_member_track_columns_head’); function mmd_member_track_columns_head( $defaults ) { … Read more

Show Different Header on a Specific Post ID

In your header.php file, you can test which page is loading and modify the markup based on this condition. For your example, the is_page() function seems ideal. <div style =”float: right; margin-top: 10px;”> <p class=”headersample3″> <?php if ( is_page( ‘###’ ) ) { ?> <a href=”https://wordpress.stackexchange.com/questions/359723/tel:555-555-5555″>555-555-5555</a> <?php } else { ?> <a href=”tel:888-888-8888″>888-888-8888</a> <?php } … Read more

Create a post in custom post type using field in registration form after users submit form

First, add the custom field to the registration form: add_action( ‘register_form’, function(){ ?> <p> <label for=”institute”>Institute</label> <input type=”text” name=”institute” class=”input” value=”” size=”25″> </p> <?php } ); Then, hook to user_register action which gets called after a user has been registered succesfully. add_action(‘user_register’,function($user_id){ $my_institute = array ( ‘post_type’ => ‘Institute’, ‘post_title’ => $_POST[‘institute’], // Custom field … Read more

Get rewrite slug of custom post type in template

You can access the post type properties using get_post_type_object(). The rewrite argument will be a property if the returned object: $post_type_object = get_post_type_object( ‘products’ ); $rewrite_slug = $post_type_object->rewrite[‘slug’]; Update I needed this for permalinks inside a template part where there are categories displayed. No you don’t. To get the URL to a category archive, use … Read more