SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Nov 2005
    Location
    Huntington Beach, CA
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wordpress custom sort by meta key

    I have a WordPress query that I need to pull out the posts that have a custom meta key of "original-document". In short I need to have all of the posts with the meta key value in 1 column and the rest of the results in another column. Any ideas on how I can accomplish this?
    Rob
    Pier Marketing ◄ Printing and Marketing Collateral - Order Online
    Pier Technologies ◄ Web Development & IT Solutions
    And That's News? ◄ My NEW Blog!!

  2. #2
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,479
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Use get_posts()

    PHP Code:
    $custom_posts get_posts( array(
        
    'posts_per_page' => 10,
        
    'orderby' => 'post_date',
        
    'order' => 'DESC',
        
    'meta_key' => 'original-document',
    ) );

    foreach ( 
    $custom_posts as $custom_post ) {
        
    //..... access all your post values in $custom_post

    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2005
    Location
    Huntington Beach, CA
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for this reply, this is what I had thought of for grabbing the original-documents, but how then do I grab everything EXCEPT the original documents?
    Rob
    Pier Marketing ◄ Printing and Marketing Collateral - Order Online
    Pier Technologies ◄ Web Development & IT Solutions
    And That's News? ◄ My NEW Blog!!

  4. #4
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,479
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    See usage of meta_query here in docs.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  5. #5
    SitePoint Zealot
    Join Date
    Nov 2005
    Location
    Huntington Beach, CA
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you again for the reply. Let me explain a little bit more. This is on a archive.php. I have built a custom filter that uses a custom post taxonomy of "classification". You can see what I have put together here http://www.constitutingamerica.org/dev2 <-- see the drop downs. Then using http://www.advancedcustomfields.com/ I have make it so a post can be tagged as an "Original Document". On this archive.php page I want to have all of my "Original Documents" on the left and all other posts on the right. Just the post titles I also want to not have any pagination on this page.
    Rob
    Pier Marketing ◄ Printing and Marketing Collateral - Order Online
    Pier Technologies ◄ Web Development & IT Solutions
    And That's News? ◄ My NEW Blog!!

  6. #6
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,479
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    As far as I can see Advanced Custom Fields plugin stores data in post meta. Taxonomy is different. So of the following what do you seek:
    1. Show posts with taxonomy 'classification' & meta key 'Original Documents' on left and remaining posts on right?
    2. Show posts with meta key 'Original Documents' on left and taxonomy 'classification' posts on right?
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •