• Hi,

    I am new to WordPress and trying to design a custom theme from the scratch. This theme will focus on showcasing my design works.

    So, on the homepage I am trying to display 4 types of services I offer (will pull the information from ‘Services’ page) and just below that section, I want to display 4 most recent portfolio items as thumbnail with permalinks.

    I have been following an old tutorial based on WordPress version 2.7.1 where instructor showed how to accomplish this using a ‘custom query’ as below:

    <?php
    	$recentBlog = new WP_Query();
    	$recentBlog =>query('showposts=1');
    	while($recentBlog->have_posts()) : $recentBlog->the_post();
    ?>

    But somewhere on internet I found that ‘showposts’ is deprecated now. I tried to find an answer on Codex section but its returning me with another confusing answer.

    This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query.

    Can anyone help me which option is would be ‘best practice’ to solve to my problem?

    Here’s a link of my theme’s layout incase you are interested.

    Thanks in advance.

  • The topic ‘WordPress custom query to display portfolio content on Homepage’ is closed to new replies.