WordPress.org

Ready to get started?Download WordPress

Forums

need to order the Admin > Edit Post list by custom field value (6 posts)

  1. niceandripe
    Member
    Posted 4 years ago #

    I'm using Custom_post_type to 'events' to my WordPress and I'm using this code to add extra columns to the Edit Events list

    add_action("manage_posts_custom_column", "events_custom_columns");
    add_filter("manage_edit-events_columns", "events_edit_columns");
    
    function events_edit_columns($columns)
    {
    	$columns = array(
    		"cb" => "<input type=\"checkbox\" />",
    		"title" => "Title",
    		"Date" => "Event Date",
    		"description" => "Description"
    	);
    	return $columns;
    }
    
    function events_custom_columns($column)
    {
    	global $post;
    	if ("ID" == $column) echo $post->ID;
    	elseif ("description" == $column) echo $post->post_content;
    	elseif ("Date" == $column) echo get_post_meta($post->ID, 'Date', true);
    }

    I would like to order the list by my 'Date' custom field, is this possible?

  2. niceandripe
    Member
    Posted 3 years ago #

    was really hoping on a response - is this at all possible without hacking the core?

  3. shahar
    Member
    Posted 3 years ago #

    Did you find a way to do this?
    I'd like to order the output by modified date as opposed to published date.
    Thanks :)

  4. Frankie Jarrett
    Member
    Posted 3 years ago #

    I was able to achieve something similar after reading this helpful article from Scribu: Custom Sortable Columns

    It's not possible to do this easily unless you're running 3.1 (which is still in RC2 as of now)

    //Frankie

  5. niceandripe
    Member
    Posted 3 years ago #

    looks promising Frankie - I'm playing with 3.1 on my dev server, so I'll look into it.

    Thanks

  6. liperuf
    Member
    Posted 3 years ago #

    Scribu and it's Custom Sortable Columns post also helped me!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.