From Scratch, using udemy course
- in the case1 wordpress will look for file content-excerpt.php if it not found it will do nothing.
//case1
get_template_part( 'partials/post/content-excerpt');
- in the case2 it will look for content-excerpt.php if not found it will look for content.php so the second case is good if u have multipale template.
get_template_part( 'partials/post/content', 'excerpt');
absoulte min require to create theme is index.php and style.css << we add the theme name in style.css
wp_enqueue_script( 'jquery' )
// if you need to modify tags and data before use (use filter hod)
add_filter( 'the_title', 'ju_title' );
// if you need perform custom action so use action hooks
add_action( 'wp_footer', 'ju_footer_shoutout' );
- how to add ajax in wordpress customizer?
- we need to use add setting define the setting, (add it to database)
- then we going to add controller with this setting, and we edit the php if statment in the place we going to have changes
- we need jquery and add this action
add_action( 'customize_preview_init', 'ju_customize_preview_init' );
- define this hock to allow ajax .
function ju_customize_preview_init() {
wp_enqueue_script(
'ju_theme_customizer',
get_theme_file_uri( '/assets/js/theme-customize.js' ),
[ 'jquery', 'customize-preview' ],
false,
true
);
}
- we have now ever thing ready, sometimes cash may make things not work clear cashe or try another browser.
// full is the size load the post thumbnail inside the loop
// second argument is the class added to the image
<?php the_post_thumbnail( 'full', ['class' => 'image_fade'] ); ?>
- ths function can't work alone in the loop becuase it need id so added the get_the_author_meta to get the author id and pass it to the function.
<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>