How to limit the number of Related Posts?

You need the argument post_per_page to limit the posts. Before your loop it should be something like this. $args = array ( ‘post_type’ => ‘custom_post’, ‘posts_per_page’ => ’10’, ); $wp_query = new WP_Query( $args ); // your loop if ( $wp_query ->have_posts() ) { while (have_posts()) : the_post(); get_template_part( ‘preview’, get_post_format() ); endwhile; } wp_reset_postdata(); … Read more

get_template_part for specific page

This is just a supplement to the other answer. I am trying to load fd-blog.php if it is the ‘Blog’ page, otherwise load the fd-default.php To actually load the template file, you should remove the dash (-): get_template_part( ‘inc/fd’, ‘blog’ ); // loads inc/fd-blog.php get_template_part( ‘inc/fd’, ‘default’ ); // loads inc/fd-default.php So just inc/fd, and … Read more

How do I display an image before the first post of the loop when I’m using get_template_part?

The variable $count is accessible in the scope of the current function only. So whatever happens inside get_template_part() cannot know that variable. You could use a global variable, which is accessible everywhere as $GLOBALS[‘count’]. But then you risk collisions with plugins and maybe other code. I recommend a helper function for the functions.php: /** * … Read more

Change the file path on get_template_part via plugin

Well, I handle this issue by adding some code above get_template_part() function in theme as: //Theme /* If any filter set */ if(has_filter(‘ppr_one_search_item_view’){ $themePartSlug = apply_filters(‘ppr_one_search_item_view’); } else{ $themePartSlug = ‘templates/search/place’; } get_template_part($themePartSlug); in my plugin: /* Plugin Code */ function get_template_part_place(){ // Template file from plugin Directory load_template(PPR1_PLUGIN_PATH.’templates/search_places.php’); } add_filter( ‘ppr_one_search_item_view’, ‘get_template_part_place’); /* plugin … Read more

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