Show number of posts AND number on current page

This should work, but I haven’t tested it: global $wp_query; $page = ( get_query_var(‘paged’) ) ? get_query_var(‘paged’) : 1; $ppp = get_query_var(‘posts_per_page’); $end = $ppp * $page; $start = $end – $ppp + 1; $total = $wp_query->found_posts; echo “Showing posts $start through $end of $total total.”;

Set font size automatically according to number of words in post

Filter ‘the_content’, count the words, and add the markup you need. You should not use str_word_count() because it has issues with numbers and utf-8. So let’s start with a word count function: /** * Alternative for str_word_count(). * * @link http://toscho.de/2012/php-woerter-zaehlen/ * @param string $str * @return int Number of words */ function t5_word_count( $str … Read more

Order Posts by Alphabetical for Each Letter

This is what I find for this question. Two codes I found were coded by MichaelH from wordpress.org. Even he won’t probably see this post, I want to thank him. Now, I just need to sort these posts from specified one category. If anyone knows how to sort them with specified category, please help me. … Read more

Show chart in post using data passed as custom field

Welcome to WPSE. The first thing to note is that you may want to put any custom code you write for this functionality into a custom plugin. This way the functionality is theme independent and available to you even, if you someday change the theme you’re using. The modern way would be to create a … Read more

Show author post count in sidebar – Variable

To get the number of posts published by a user i found the solution was to call count_user_posts(), passing in the appropriate user id. <?php echo ‘Posts made: ‘ . count_user_posts( get_the_author_meta(‘ID’) ); ?> In translation ready form. <?php printf( ‘Posts made: %d’, count_user_posts( get_the_author_meta(‘ID’) ) ); ?> Storage in a variable. <?php $user_post_count = … Read more

Adding a Nav menu to post admin

To see how such a list can be created look at the code in wp-admin/includes/nav-menu.php. Unfortunately, it is hard coded there, so you have to re-create the code. First, let’s create two menus: We can get these menus in PHP with wp_get_nav_menus() (a wrapper for get_terms()): $menus = wp_get_nav_menus(); print ‘<pre>’ . htmlspecialchars( print_r( $menus, … Read more

How to remove_filter that filters iframes in posts? [duplicate]

This filter does not. This feature is disabled in the visual editor TinyMCE. function wpse49619_change_mce_options($initArray) { $ext=”iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]”; if ( isset( $initArray[‘extended_valid_elements’] ) ) { $initArray[‘extended_valid_elements’] .= ‘,’ . $ext; } else { $initArray[‘extended_valid_elements’] = $ext; } // maybe; set tiny paramter verify_html //$initArray[‘verify_html’] = false; return $initArray; } add_filter(‘tiny_mce_before_init’, ‘wpse49619_change_mce_options’); Also you can use examples … Read more