Register widget in wordpress

function my_custom_theme_widgets() {
	register_sidebar( array(
		'name' => 'My Widget',
		'id' => 'widget_id',
		'before_widget' => '<div class="widget_div">',
		'after_widget' => '</div>',
		'before_title' => '<h2>',
		'after_title' => '</h2>',
	) );
}
add_action('widgets_init', 'my_custom_theme_widgets');

You can call widget via below:

Single widget:

<?php dynamic_sidebar('widget_id'); ?>

Conditional

<?php if ( ! dynamic_sidebar( 'sidebar-top' ) ) : ?>
// Your conditional codes
<?php endif; ?>

Shortcode inside custom post wordpress

function post_list_shortcode($atts){
	extract( shortcode_atts( array(
		'count' => '',
	), $atts) );
	
    $q = new WP_Query(
        array('posts_per_page' => $count, 'post_type' => 'posttype', 'orderby' => 'menu_order','order' => 'ASC')
        );		
		
	$list = '<div class="custom_post_list">';
	while($q->have_posts()) : $q->the_post();
		$idd = get_the_ID();
		$custom_field = get_post_meta($idd, 'custom_field', true);
        $post_content = get_the_content();
		$list .= '
		<div class="single_post_item">
            <h2>' .do_shortcode( get_the_title() ). '</h2>
			'.wpautop( $post_content ).'
            <p>'.$custom_field.'</p>
		</div>
		';        
	endwhile;
	$list.= '</div>';
	wp_reset_query();
	return $list;
}
add_shortcode('post_list', 'post_list_shortcode');	

Custom post loop with custom fields

<?php
global $post;
$args = array( 'posts_per_page' => -1, 'post_type'=> 'posttype', 'orderby' => 'menu_order', 'order' => 'ASC' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>

<?php 
   $job_link= get_post_meta($post->ID, 'job_instructions', true); 
?>

	<h2><?php the_title(); ?></h2>
	<?php the_content(); ?>
	<p><?php echo $job_link; ?></p>
<?php endforeach; wp_reset_query(); ?>

WordPress image crop

add_theme_support( 'post-thumbnails');

WordPress crop an image = 5 size. Sizes are given below

thumbnail: Thumbnail (default 150px x 150px max)
medium: Medium resolution (default 300px x 300px max)
large: Large resolution (default 640px x 640px max)
full: Original image resolution (unmodified)

But, if you need custom size, you can define sizes in functions.php

add_image_size( 'post-image', 600, 200, true );

Using the sized image in your loop

Image URL

If you want to use wordpress resize just add your size, I’ve added large size image in example

$image_variable = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' ); echo $image_variable[0];

If you want to use your custom size

$image_variable = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-image' ); echo $image_variable[0];