divider

Fixing the get_posts() Query for Custom Post Types

Services: Law Firm Website Design . SEO . Internet Marketing . Law Firm Marketing Guide . Content Marketing . PPC

As we start to develop larger  WordPress sites, one thing becomes apparent: backend organization can become very confusing for clients.

At PaperStreet Web Design, we have come up with a solution that deals with a combination of two WordPress Plugins.  The two plugins are Custom Post Types UI and Advanced Custom Fields.

The combination of these two plugins will allow you to create custom post types in the WordPress Dashboard area, then customize them to be specific to your page layouts.  As a law firm web design studio the most common scenario when we would use this method would be to separate general pages, blog posts, practice areas and attorney profiles.

Previously, we would have just added all the Practice areas, Attorneys, etc., under Pages in the WordPress Dashboard area.  However, this can get very confusing if you have 100 Attorneys, 100 Practice areas and even more pages.

Creating one Custom Post Type for Attorneys and one for Practice Areas can separate the content greatly for the client, allowing them to have a very organized, clean backend WordPress Dashboard area to edit their site with.

Common Issue for Custom Post Types and the get_posts() Query

However, a common issue we have run into while working with these plugins is using the get_posts() WordPress function.

Typically, we could pass in a value such as:
‘post_type’ => ‘attorneys’

This should work.  However – if it does not – what can you do?

Solve the get_posts() function not working for custom post type problem in 1 simple step.

The problem is not your code!  In the WordPress Dashboard area go to Custom Post Types > Manage Custom Post Types, then select ‘Edit’ for the particular Post Type you are having issues with.  Open up the ‘Advanced Options’ on the left side.  Scroll down to where it says ‘Hierarchical’ and select ‘True’.

enable_hierarchical

Once ‘True’ is selected for Hierarchical, your get_posts() query for the custom post type should now work properly.

It is important to know how to fix these minor issues because these are the foundations for a well-organized law firm website.  Separating the templates into custom post types will allow the client  to feel accomplished when they log into the Dashboard area, as everything becomes more intuitive.

If you are interested in working with PaperStreet on a law firm website please contact us today for a free evaluation and consultation.


Related Posts

Ready to Take Your Website to the Next Level? Great Ideas & Results Only a Phone Call Away

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Let's get started.

Leave a Reply

Your email address will not be published. Required fields are marked *

*