Support » Plugin: Custom Content Type Manager » Print custom fields in Alphabetical order

  • I am using CCTM to build a Literary Agency website.

    The page I’m stuck on is the Authors page which displays Thumbnails of all the books related to the author at the bottom of the authors profile. Pls see link here. The code i have below does just that, however I want it displayed in Alphabetical order. I’ve tried using many solutions, but i’m not quite sure how to incorporate any solutions into my existing code. Any help is greatly appreciated.

    This is the code

    <?php if (get_custom_field("authimage:get_post")):?>
    <div class="thumbstrip">
    <h4>Titles by this Author</h4>
    <?php $my_post = get_custom_field("authimage:get_post");
            foreach ($my_post as $a) {
                print '<li><a href="'. $a['permalink'] .'" title="'. $a['post_title'] .'"><img src="'.$a ['thumbnail_src'].'" /></a></li>';
    <?php endif;?>

Viewing 1 replies (of 1 total)
  • Plugin Contributor fireproofsocks


    That’s tough: your query returns IMAGES, not actual posts. So they don’t necessarily contain info re a title — they can, but it’s not required in the same way it’s required for say, a post, or a page.

    Reading IDs out of a relation custom field (an image relation in your case), returns the IDs in the order they were stored in — you can click and drag them into a custom sort order, but get_custom_field is not built to do custom sorting.

    But let’s back-up: from what you’re describing, I think your data model should be structured differently, and that’s usually at the root of a majority of the forum questions. If you have a custom post type for authors and books, then the post ID for the author pages essentially is treated as the “author ID” (not to be confused with the WP internals tracking user ID that goes by the same name). As such, you would query for posts where post_type=books and the author matches the id of page you’re looking at. You can accomplish this with WP_Query or the other WP functions, but I found them to be problematic and full of exceptions, so I wrote the GetPostsQuery class to do queries like that. Maybe you should review the wiki with examples there and see if that’s at all what you need.

Viewing 1 replies (of 1 total)
  • The topic ‘Print custom fields in Alphabetical order’ is closed to new replies.