When to use content-pagename.php?

Usually the format you see in themes are content-{$post_format-term}.php or content-{$pagename}.php, but it is not restricted to this formats. The naming convention can also differ to your liking as long as you keep it out of normal template hierarchy and then use get_template_part to call it correctly. These are not self standing templates, they cannot … Read more

Display images in template file

if You wish to display an image, which is a thumbnail of a post, then use: <?php echo get_the_post_thumbnail( $pageID, ‘thumbnail’ ); ?> if You wish to display an image from media, then use <?php echo wp_get_attachment_image( $attachmentID, ‘thumbnail’ ); ?> thumbnail is set for size and is set by default. Size can be changed … Read more

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; }