Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • I got it working by running this CLI script:
    wp --url=example.com co-authors-plus create-terms-for-posts which updates all the posts with the taxonomy. I also had to fix a blocking issue in the actual script class-wp-cli.php changing line 81 from

    WP_CLI::error
    to
    WP_CLI::line

    Then I could use my custom WP_Query and all looks to be working!

    This is the working query and loop for author.php:

    <?php 
    $user_name = get_the_author_meta('user_login');
    $args = array( 
        'tax_query' => array(
            array(
                'taxonomy' => 'author',
                'terms' => $user_name,
                'field' => 'name',            
            ),
                        ),
    );
    $author_query = new WP_Query( $args );
    while  ( $author_query->have_posts() ) : $author_query->the_post(); 
    get_template_part('article', 'archive');
    endwhile; ?>

    Thanks again for pointing me in the right direction!

    • This reply was modified 8 years, 2 months ago by silasmiller.

    Interesting. I’m hesitant to try run it on all posts, but hey that’s a what a dev environment is for!

    Thanks again. I’ll let you know if that works. If it helps someone else with the issue that would be great.

    Ah it seems that the plugin doesn’t add the taxonomy to all the existing posts. So it only shows the ones that have been saved since it was installed. Using a custom WP_Query I can get the posts with the co-author set to either the 1st or 2nd slot, but the old posts don’t have the taxonomy.

    I put this in my author.php file for my theme

    <?php 
    $user_name = get_the_author_meta('user_login');
    $args = array( 
        'tax_query' => array(
            array(
                'taxonomy' => 'author',
                'terms' => $user_name,
                'field' => 'name',            
            ),
                        ),
    );
    $author_query = new WP_Query( $args );
    ?>

    Then replaced the post loop with:

    <?php 
        while  ( $author_query->have_posts() ) : $author_query->the_post(); 
        ?>

    Now I just need to find a way to scan all the existing posts and add the taxonomy entry for them.

    Ideas? Seems like I’m going to have to just go write a MySQL query to accomplish.

    Thanks again!

    Interesting. I just looked and it seems that Co-Authors isn’t changing the query for author.php, which is why I tried using WP_Query, but I can’t seem to use ‘OR’ to go for a taxonomy and normal author . Maybe I’m missing something.

    Could it be related to the twentyeleven_posted_on function? I’ve modified that a couple different ways but it doesn’t seem to help.

    I’m happy to hack or write new code, but I feel like WordPress obfuscates enough that it’s hard compared to normal MVC systems I’m used to.

    I’m having the same issue and tried this fix, but still not seeing posts on the author Archive for Authors that are the coauthors. I can get those by adding a modified WP_Query to the author page, but then it only shows posts where they are co-authors(either first or second), and not the posts where they are just the single author.

    Would rather not have to buy Bylines…. Any other thoughts? Thank You Sean.

    • This reply was modified 8 years, 2 months ago by silasmiller. Reason: clarification
Viewing 5 replies - 1 through 5 (of 5 total)