Pagination broken on is_front_page()

According to the WP_Query docs: Pagination Note: Use get_query_var(‘page’); if you want your query to work in a Page template that you’ve set as your static front page. The query variable ‘page’ also holds the pagenumber for a single paginated Post or Page that includes the Quicktag in the post content. Display posts from current … Read more

Prev/Next Links Broken on Static Front Page Pagination

previous_posts_link() echos the result of get_previous_posts_link() which checks the paged query variable, not the page query variable used on static pages. You will have to write your own code to display the link on a static page. I didn’t test it, but you might try fooling WordPress: function homepage_test() { global $paged; Now your changes … Read more

stripping tags from excerpt in WordPress is not working

the_excerpt() automatically echoes the excerpt text. What you need is get_the_excerpt(): <a href=”https://wordpress.stackexchange.com/questions/108530/<?php the_permalink() ?>” title=”<?php echo strip_tags( get_the_excerpt() ); ?>”> However, it probably won’t strip out ellipses (…) since they’re HTML entities, not tags.

Displaying posts based on category

Add category_name or cat in your arguments (args) array. <div id=”mini_stream”> <ul> <? $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 4, ‘category_name’=>’html’, ); $loop = new wp_Query($args); while($loop->have_posts()) : $loop->the_post(); echo ‘<a href=”‘.get_permalink().'”>’; echo get_the_post_thumbnail($post->ID, ‘category-thumb’); the_title( ‘<h6>’, ‘</h6>’ ); echo ‘</a>’; endwhile; wp_reset_query(); ?> </ul> </div>

Skip foreach loop

In line 195 you’re using get_categories, which can be filtered to exclude specific category numbers, either through an array of arguments, or a query string. Since $options is already set, you could add to it before you call get_categories: if ($show_assigned_categories == ‘true’ && is_single()) { $categories = get_the_category(); } else { $options[‘exclude’] = ‘1,2,3’; … Read more

Detecting if parent page has gallery

It happens because strpos returns 0 (zero index position) when gallery shortcode is at the start of the content which is treated as false by the if condition. Solution is to use Identical operator === in condition to check if the return value is a boolean false.

Remove the More Link

You need a filter on the_content_more_link. else { // They aren’t in the paying group function strip_more_link($link,$linktext) { remove_filter(‘the_content_more_link’,’strip_more_link’,1); return $linktext; } add_filter(‘the_content_more_link’,’strip_more_link’,1,2); global $more; $more = 0; the_content(‘<b>Interested in reading the rest of this article? You just be a subscriber to continue reading.</b>’); } It may be more efficient, or neater, to write a … Read more

Shortcode to find and replace URL

Your shortcode function should look like this: function replace_url_for_nonlogged( $atts, $content = “”) { if ( is_user_logged_in () ) return $content; extract( shortcode_atts( array( ‘replace’ => ‘http://www.default_replace_url.com’, ), $atts ) ); $pattern = ‘/href=(“|\’)((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)(“|\’)/’; return preg_replace($pattern, “href=\”$replace\””, $content); } add_shortcode( ‘scode’, ‘replace_url_for_nonlogged’ ); Then you can use the shortcode like this: [scode]Lorem <a href=”http://reservedurl.com”>ipsum</a> dolor … Read more