JSFiddle - React, Tailwind, and code Playground
by rvpatel
JavaScript
<?php
//get postthumbnail url
if (has_post_thumbnail()) {
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail_name');
echo $thumb[0]; // thumbnail url
}
//Show Different Number Of Posts Per Category In WordPress
add_action('pre_get_posts', 'diff_post_count_per_cat');
function diff_post_count_per_cat() {
if (is_admin()) return;
$cat = get_query_var('category_name');
switch ($cat) {
case 'wordpress':
set_query_var('posts_per_page', 5);
break;
case 'wordpress/news':
set_query_var('posts_per_page', 2);
break;
}
}
//Change WordPress Default Email From Name And Address
add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
function new_mail_from($old) {
return '[email protected]';
}
function new_mail_from_name($old) {
return 'Your Blog Name';
}
//wordpress staring generate your url
define( 'HOME_URI', home_url() );
define( 'THEME_URI', get_stylesheet_directory_uri() );
define( 'THEME_IMAGES', THEME_URI . '/images' );
define( 'THEME_CSS', THEME_URI . '/css' );
define( 'THEME_JS', THEME_URI . '/js' );
//and use them when needed, for ex. to include favicon, use
?> <link href="< ?php echo THEME_URI; ?>/favicon.ico" rel="shortcut icon" />
<?php
//Remove author link in comments for WordPress 2.7 and newer
wp_list_comments();
//with:
wp_list_comments('callback=mytheme_comment');
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
<?php printf(__('<cite...