Showing “best posts” in front page

If you can live with manually deciding what your best posts are, Sticky Posts would be the way I´d choose. The Codex already has code for the 5 latest sticky posts: /* Sort Sticky Posts, newest at the top */ rsort( $sticky ); /* Get top 5 Sticky Posts */ $sticky = array_slice( $sticky, 0, … Read more

Best way to change the blog page post type?

You may edit the query using the pre_get_posts action. You can do something like this: add_action(‘pre_get_posts’,’wpse_218948_search_filter’); function wpse_218948_search_filter(){ if( is_page(‘blog’) /* or whatever page it is */ && $query->is_main_query() ){ $query->set(‘post_type’, ‘blog’); # query post type “blog” $query->set( ‘posts_per_page’, -1 ); # display all posts } }

Customizing a blog page layout

Copied from the WordPress developer documentation on ‘Template Hierachy’, the blog template is displayed using the following template file rules: If your blog is at http://example.com/blog/ and a visitor clicks on a link to a category page such as http://example.com/blog/category/your-cat/, WordPress looks for a template file in the current theme’s directory that matches the category’s … Read more

How to remove the h6 tag for the entry-category Class

You don’t need functions for this, just look in your theme’s template files: For single posts check single.php and for blog archive/categories check archive.php. Change the <h6> in those php files to <div> or whatever you want. It would be wiser to override them with a child theme so you don’t lose your changes in … Read more

Display a single category in blog section

In WordPress, we have what is called as “main query” which points to the global $wp_query object (which is an instance of the WP_Query class), and this main query is run on page load after WordPress parses query arguments from the current URL (or the relevant query for the matching rewrite rule for that URL). … Read more

Exclude Custom post type from /blog page

you can try this one function exclude_some_post_type($query) { if ( ! is_admin() && $query->is_main_query() ) { if ( $query->is_search || is_home() ) { // in search page $query->set( ‘post_type’, ‘post’ ); } } } add_action( ‘pre_get_posts’, ‘exclude_some_post_type’ ); The function that applied to a pre_get_posts hook will set only default post type (post), and will … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)