Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter op.3no.2

    (@op3no2)

    Nevermind, I figured it out!

    For anyone who is curious, you have to call
    {$wpdb->prefix}term_relationships
    {$wpdb->prefix}term_taxonomy
    {$wpdb->prefix}posts

    and find where they intersect to pipe a certain category to a page.

    Then, to make shortcodes for different categories, edit your functions.php [like so: //INSERT CATEGORY 9
    function wpmp_category9_products($params){
    include(WPMP_BASE_DIR.’tpls/catalog_category9pianos.php’);
    }]
    and hooks.php [example: //ADD SHORTCODE FOR CATEGORY 9
    add_shortcode(“wpmp-category9”, “wpmp_category9_products”); ].

    So if any of you are curious about how to make shortcodes to pull products from certain categories to a page, feel free to message me.

    Thread Starter op.3no.2

    (@op3no2)

    Actually, I’ll just post exactly how I did it here.

    1. Go to FTP, find /wpmarketplace/tpls folder. In there you will find catalog_feature.php. This is the file that calls featured products, so we’re just going to replicate it to call different categories.

    2. Copy the code from that file to a different file, which you’ll name according to the category that you want. Say, catalog_category1.php.

    3. Find in the code:
    $featured_products=$wpdb->get_results(“select * from {$wpdb->prefix}mp_feature_products fp inner join {$wpdb->prefix}posts p on p.ID=fp.productid where p.post_type=’wpmarketplace’ “);

    foreach($featured_products as $key => $value):
    query_posts( ‘post_type=wpmarketplace&posts_per_page=1&p=’ .$value->ID);

    ^^^This is what you will edit to call a certain category.

    4. Open up MySQL from your hosting service’s webpanel. You’ll probably have to learn/know a little SQL here but there are excellent resources online to guide you. Search your database for where your wpmarketplace categories are stored. In my case, and perhaps yours, it is
    _term_relationships
    _term_taxonomy

    5. Find the numbers that uniquely identify a category. In my case, it was term_taxonomy_id inside term_relationships.

    6. Here’s what I used to call the posts I need:

    select * from {$wpdb->prefix}term_relationships tr, {$wpdb->prefix}term_taxonomy tt, {$wpdb->prefix}posts p
    WHERE p.ID=tr.object_id
    AND p.post_type=’wpmarketplace’
    AND tr.term_taxonomy_id=’10’ [<– YOU CHANGE #]
    AND tt.term_taxonomy_id=’1′

    Tweak the numbers according to your site, then run it through your MySQL to check that it returns the posts you need. I added tt.term_taxonomy_id=’1′ because without it I got like 10 duplicates of the same post.

    7. Use that code to replace the code in catalog_category1.php, like so:

    $[XXX MAKE UP A TERM]=$wpdb->get_results(“select * from {$wpdb->prefix}term_relationships tr, {$wpdb->prefix}term_taxonomy tt, {$wpdb->prefix}posts p
    WHERE p.ID=tr.object_id
    AND p.post_type=’wpmarketplace’
    AND tr.term_taxonomy_id=’10’
    AND tt.term_taxonomy_id=’1′”);

    foreach($[XXX SAME AS ABOVE] as $key => $value):
    query_posts( ‘post_type=wpmarketplace&posts_per_page=1&p=’ .$value->ID);

    8. Now edit functions.php and hooks.php as I mentioned in above comment (except change the names to match your own), and update the files in your FTP. Remember to add your newly created catalog_category1.php file to FTP.

    Like so:

    functions.php:
    //INSERT CATEGORY 1
    function wpmp_category1($params){
    include(WPMP_BASE_DIR.’tpls/catalog_category1.php’);
    }

    hooks.php:
    //ADD SHORTCODE FOR CATEGORY 1
    add_shortcode(“wpmp-category1”, “wpmp_category1”);

    9. Add your shortcode to the page that you want (in hooks.php: add_shortcode(“wpmp-category1”[<—THIS PART IS THE SHORTCODE], “wpmp_category1”)(so I will add [wpmp-category1] to the text editor of my page).

    10. Hopefully it works for you! Repeat for all your different categories.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Find categories in MySql’ is closed to new replies.