1. add page-attributes uner ‘supports’ Continue Reading
Category: Code
Custom Post Pagination not working
Custom post query
- post type download
- post content style content-item.php
- post pagination function st_posts_pagination
<?php global $wp_query; query_posts( array('post_type' => array( 'download' ), 'paged'=>$paged ) );?> <?php if(have_posts()) : while (have_posts() ) : the_post(); ?> <?php get_template_part('content', 'item'); ?> <?php endwhile; ?> <?php ?> <div class="col-md-12"> <div class="page-link text-center"> <?php st_posts_pagination(); ?> </div> </div> <?php endif; ?>
wp-content/uploads not working on Nginx
Use this command
chown -R www-data:www-data /var/www
Add class on categories widget for post counter styling
function rm_categories_post_count_filter ($cat_post_count) { $cat_post_count = str_replace('(', '<span class="post_count pull-right"> (', $cat_post_count); $cat_post_count = str_replace(')', ' )</span>', $cat_post_count); return $cat_post_count; } add_filter('wp_list_categories','rm_categories_post_count_filter');
Limiting WP Post content and adding conditional Read More button
Content limit 110 words.
<?php $trimexcerpt = get_the_content(); $shortexcerpt = wp_trim_words( $trimexcerpt, $num_words = 110, $more = ' [...]' ); echo "<p>" .$shortexcerpt. "</p>"; ?>
After 110 words show “Read More”
<?php $count = str_word_count($shortexcerpt); if($count >= 110){ ?> <a href="<?php the_permalink(); ?>" class="st-more-link text-center text-uppercase"><span><?php _e('Read More', 'cherry') ?></span></a> <?php } ?>