Custom Post Type Loop Explanation, and Possibly Help?

Discussion in 'GeoCraft WordPress Theme' started by kentoliver, Mar 19, 2013.

Thread Status:
Not open for further replies.
  1. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Hey there InkThemes,

    I see that there is a way to search and filter the contractor listings. I was wondering if you could help me solve a problem with some functionality I am trying to implement into this theme.

    Say I have a string holding a variable:
    $my_string = 'DESC';


    Can I display the loop of contractors to display in descending order? Or better yet to display using a string passed through by input fields? Essentially I am trying to create a filter for the contractors, so that after the user searches. They have the option to view ascending order, descending order, and by id, and perhaps some other things I am thinking of.

    That sounded a bit confusing. Really I am trying to figure out how to display the contractor loop, in a different way other then by most recent.

    Once I figure out how the Custom Post Type is being called, I can figure out the rest myself.
    Thanks!
     
  2. Gourav

    Gourav Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    7,728
    Likes Received:
    207
    Can you please tell us the link of your website.

    Is this "contractor" a category ?
     
  3. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    I am sorry the Contractor is just the listing custom post type. Forget the word contractor, and focus on the listing part.

    I am trying to figure out how I can display the list of listings in a different order then just Recently Added.

    Ideally I am adding a Filter functionality, where the user can change the list of contractors on the homepage.

    So my thought process is pretty much using a similar one to your search-loop functionality, where there is a string holding the sort type, then to call it with issets and inputs.

    I am working on a test site, and I will share with the InkThemes community once it is ready for launch.

    However if the test site is needed to understand what I am trying to convey, then that is not a problem.
    -Kent Oliver
     
  4. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
  5. Gourav

    Gourav Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    7,728
    Likes Received:
    207
    We have created the loop in a way that if there are any sticky listings they appear on the top.

    If no listings are marked as sticky, they are shown in the Recently added fashion.

    If you want to customize the query in anyways, you can do so from the front-page.php file, you can sort the listings in descending ways as required.

    Check the screenshot below.
    http://screencast.com/t/ZhC7HvEOWb


    Similarly if you have any Sticky listings, you can order them through the code in the same file few lines above.
     
    kentoliver likes this.
  6. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Thanks so much Gourav for the screenshot.

    I will let you know if I figure out the click-sort functionality.
    All the best,
    -Kent
     
  7. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Hey again,

    I added that line of code, however it does not look to change the outcome at all...

    query_posts(array(
    'post__in' => $sticky,
    'ignore_sticky_posts' => 1,
    'post_type' => $post_type,
    'showposts' => $limit,
    'paged' => $paged,
    'order' => 'DESC'
    ));

    I tried multiple SQL sorting syntax, and all turned out the same.
     
  8. aliounn

    aliounn Member

    Joined:
    Dec 7, 2012
    Messages:
    136
    Likes Received:
    6
    Hi Kentoliver,
    your web site looks very nice ! good job
    how did you add the big home page slider ? i like it
     
  9. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Hey there aliounn

    All I did was break the wrapper to get the 100%, then i re-made it, and then its just a slider plugin.
    I believe the plugin is called:
    uBillboard
     
  10. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Found the solution. I just pasted the code in the sticky part by mistake ><

    Thanks again Gourav!
     
  11. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Now if you know of how to make it sort randomly. You have my project all wrapped up :p

    any tips from anyone on making the posts sort randomly would be greatly appreciated.
     
  12. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Found my own solution.
    instead of using:
    'order' => 'rand'
    i tried:
    'orderby' => 'rand'


    And it works. Now to create the ifs and buts and then I will be home free.

    Thanks again for all the help. Solid support forum.
     
    Krish likes this.
  13. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    if anyone wants to randomize the featured slider. this is how i accomplished it:
    <?php
    $count = 1;
    $class = '';
    $check = false;
    query_posts(array(
    'post_type' => POST_TYPE,
    'showposts' => 500,
    'orderby' => 'rand',
    'meta_query' => array(
    array(
    'key' => 'geocraft_f_checkbox1',
    'value' => 'on',
    'compare' => 'NOT NULL',

    )
    )
    ));
    if (have_posts()) :
    ?>
     
    Krish likes this.
  14. aliounn

    aliounn Member

    Joined:
    Dec 7, 2012
    Messages:
    136
    Likes Received:
    6
    Thank you very much for all your posts
     
  15. Krish

    Krish Support Staff

    Joined:
    Oct 22, 2012
    Messages:
    210
    Likes Received:
    1
    Location:
    India
    Your website looks really great with all the customizations. Cheers.

    Thanks
    Krish

     
  16. kentoliver

    kentoliver Active Member

    Joined:
    Jan 3, 2013
    Messages:
    238
    Likes Received:
    41
    Thanks alot Krish!

    Has taken up a bit of my time ;)
     
Thread Status:
Not open for further replies.

Share This Page