WordPress.org

Ready to get started?Download WordPress

Forums

Business Directory Plugin
[resolved] List Titles under Categories (3 posts)

  1. fidgeter
    Member
    Posted 1 year ago #

    I'm attempting to do a main listings page with everyone in the directory sorted alphabetically under the Category.
    Similar to this page: http://www.health-first.org/physician/hfmg_list.cfm

    Now what I've done is run a query for posts within the WPBDP_POST_TYPE. The Categories for BDP is different than the stock wordpress Categories so I can't use $args to establish categories, correct? What I've done is below but I'm afraid if I have to run Queries for each category it'll slow the page down. Is there a better way to do this or a command within BDP I've missed?

    An example of what I've done to pull the ones that are in "category 5".

    $args = array( 'post_type' => WPBDP_POST_TYPE, 'orderby' => 'title', 'order' => 'ASC' );
    
    	<?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
    	<?php $value = wp_get_object_terms( $id, WPBDP_CATEGORY_TAX, array( 'fields' => 'ids' ) ); ?>
        <?php if(in_array("5", $value)): ?>
    	<p><a href="<?php the_permalink(); ?>">
        <?php the_title(); ?>
        </a></p>
    	<?php endif; ?>
    
    	<?php endwhile; ?>
        <?php endif; ?>
    <?php wp_reset_query(); ?>

    http://wordpress.org/extend/plugins/business-directory-plugin/

  2. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    I don't know if there's a better way to do it than what you have above. But your concern is valid, you could have performance problems with excessive category subqueries.

  3. fidgeter
    Member
    Posted 1 year ago #

    Thank you for your response. My optimal solution may be to just not have it query at all and manually create the page with the list and link them to the relevant Business Directory pages. It's a little more work on my part but would mean a lot less overhead for the server.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.