• Can anyone tell me how to set the $curauth variable, so that posts are called up by their “display name” rather than by their “author name”????

    The reason for this is because I have a number of businesses that have different staff inputing posts on their companies behalf and each author is registred under a different username(auhorname).

    In order for their posts to be listed under the same business name, each author for that company has been instructed to add their company name as their nickname and for that to be used as their display name.

    Hope that makes sense.

    By doing this all auhtors from the same company are able to input their posts and have all posts come up under the company name.

    I want the option display all posts by that compnay rather than all posts by one author

    Any ideas? Is it even possible?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Your best option is to use a custom taxonomy to associate posts with an organization. The organization itself will be the term in the taxonomy. Through the save_post hook, you can forcibly assign companies to posts based on the post’s author. I’d suggest creating an options page to manage author-company mappings.

    Thread Starter starflow

    (@starflow)

    This is the code I am trying to alter…

    <?php

    //This sets the $curauth variable
    if ( isset($_GET[‘author_name’]) ) :
    $curauth = get_userdatabylogin($author_name);
    else :
    $curauth = get_userdata( intval($author) );
    endif;

    ?>

    and…

    <?php
    // show all random ads but make sure the sticky featured ads don’t show up first
    $paged = ( get_query_var(‘paged’) ) ? get_query_var(‘paged’) : 1;
    query_posts( array(‘post_type’ => APP_POST_TYPE, ‘post_status’ => ‘publish’, ‘display_name’ => $curauth->ID) );
    ?>

    Thread Starter starflow

    (@starflow)

    Thanks for your reply Erik, but what you suggested just went completely over my head – I am a WP novice ??

    Thread Starter starflow

    (@starflow)

    Can someone please simplify and expand on what Erik suggested or at least have another suggestion based on the coade above?

    Unfortunately, what you’re trying to do isn’t natively supported by WordPress, making it a relatively complicated undertaking. I did this recently for a client and the functional aspect alone took several hours.

    Do you have any experience using WordPress’ actions and filters, creating custom taxonomies, or adding options pages to WordPress?

    Thread Starter starflow

    (@starflow)

    None at all!

    However, I am in contact with someone who understands PHP coding well, so if you can give me some clarity on what code to alter and where, hopefully he will have a better understanding of what can be done to achieve what I want.

    To me, logically it should be a simple case of redirecting the search results to display posts by “display_name” rather than “authorname”, but nothing is ever as easy as it sounds is it!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Get posts by "display_name" NOT "author" name’ is closed to new replies.