Display number of posts via adress bar?

If you’re asking to change the number of posts from 10 to something else, you can do one of the following 1) Submit the search query as ?s=key&order=ASC&posts_per_page=5 You can achieve this by adding hidden fields to the form. Just change the number to whatever you want 2) Go to Settings > Reading, change the … Read more

The short content by characters [duplicate]

There are no built-in WordPress functions to trim strings by character count. /** * Get a limited part of the content – sans html tags and shortcodes – * according to the amount written in $limit. Make sure words aren’t cut in the middle * @param int $limit – number of characters * @return string … Read more

Check to see if post is live before displaying the content

Your custom function show_post() uses get_page_by_slug() to retrieve the specified page. Looking at source, it doesn’t look like get_page_by_slug() uses post_status. So, you’ll need to query $post->post_status within your show_post() function if you want to account for it in the function output: <?php function show_post( $path ) { $post = get_page_by_path( $path ); $content=””; if … Read more

Sidebar links for different pages

Register a new sidebar by pasting this into your theme’s functions.php file: register_sidebars( ‘id’ => ‘patientedu’ ); Create a file called sidebar-patientedu.php and paste the following into it: <?php if (is_active_sidebar(‘patientedu’)) : ?> <div id=”sidebar”> <h2>PatientEdu Sidebar</h2> <?php dynamic_sidebar(‘patientedu’); ?> </div> <?php endif; ?> Then paste this whereever you want your sidebar to show up: … Read more

How can i sort the categories by ID

wp_list_categories takes an orderby parameter which accepts : ID – Default name slug count term_group So the default behavior of wp-list-categories is to order by ID but you can specify that like so: <?php wp_list_categories(array(‘exclude’=> 73,’orderby’ => ‘ID’));?>

How to filter posts that belong to a specific category only if that is the only category

You will need more than one query because before querying posts you have to know what posts to exclude. I personally don’t see anything bad in ‘cutoff’. This code should work properly: Update: It breaks pagination (see comments). <?php $category_to_filter = 11; while ( have_posts() ) : the_post(); $categories = get_the_category(); if( in_array($category_to_filter, $categories) && … Read more

Animated gif for a thumbs

To use gifs in WordPress you need to insert the full size of the uploaded gif (the original size). In the Media Box : Size: Full Size Any other size you choose will not render because of how GD crops and re-sizes the photos, it does so by taking a single frame, to make it … Read more