Homepage custom recent news

Assuming this is the default main query, see the example for pre_get_posts, which shows how to exclude a category from the main query: function wpa78465_exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-1,-1347’ ); // IDs of categories to exclude } } add_action( ‘pre_get_posts’, ‘wpa78465_exclude_category’ );

Manual excerpt length on recent posts slider

The line below the one you edited computes the edited words based on the height and width of the slider box. The value you added is changed on the next line. Avoid editing the plugin file. Next time you update the plugin your changes will be lost. You should be able to change the Excerpt … Read more

Where to add offset?

<?php $recent = new WP_Query( array( ‘tag’ => get_option(‘gd_slider_tags’), ‘posts_per_page’ => get_option(‘gd_slider_num’), ‘offset’ => 1) ); while($recent->have_posts()) : $recent->the_post();?>

Showing recent post of category in page

Here is a start. This is how I display related posts from the category the post are in. You will just need to add your own loop and CSS Create a template called content-related.php Inside that paste the following code <?php /** * The default template for displaying realted posts * * @package WordPress * … Read more

Problem with Front-Page.php loading recent posts

You have to reset every instance of a custom query, otherwise you will get unexpected output from any other query there after Simply use wp_reset_postdata() after every custom query. Example <?php $args = array( ‘numberposts’ => ‘1’, ‘meta_key’=>’_thumbnail_id’ ); $recent_posts = wp_get_recent_posts( $args ); foreach($recent_posts as $post) : ?> <?php get_template_part( ‘content’, ” ); ?> … Read more

Adding a badge to new blog post titles

You want to edit the title, and not the content. Check this for filters you want to use. If you want to edit your title you should add_filter to it and modify it(the_title). Like so: add_filter(‘the_title’, ‘addBadge2Title’); function addBadge2Title($title) { $seconds = strtotime(“now”) – strtotime(get_the_date(“Y/m/d”)); $badge = get_stylesheet_directory_uri() . ‘/library/images/new_ribbon.gif’; if ($seconds < 10950400) { … Read more

Get x recent posts by author?

The function you are using, get_most_recent_post_of_user, won’t work as it only retrieves the latest post from the author. It cannot retieve a list of posts Walks through each of a user’s blogs to find the post with the most recent post_date_gmt. You will most probably be better of using either WP_Query or get_posts to achieve … Read more

Why aren’t paragraphs breaking on this page?

get_the_content() returns unfiltered content, and using a shortcode you cannot use the_content() to return filtered content as you cannot echo inside a shortcode. Your best option here will be is to applying the_content filters to get_the_content(), something like: apply_filters( ‘the_content’, get_the_content() ); EDIT Exact usage, replace $output .= get_the_content(); with $output .= apply_filters( ‘the_content’, get_the_content() … Read more