• feisthammel

    (@feisthammel)


    Very simply, what I’d like to do is add the posts URL of the last editor with get_author_posts_url, but I can’t for the life of me figure out how to successfully extract the user ID from get_the_modified_author. I know how to pull it out and print it, but nothing I’ve tried has successfully prompted get_author_posts_url to use the correct ID.

    Any ideas? What painfully obvious PHP magic am I missing here? For reference and convenience, I’ve pasted relevant functions below. Thanks for your help!

    [code moderated - please use the pastebin for any code over 10 lines]

    function get_the_modified_author() {
    	global $post;
    	if ( $last_id = get_post_meta($post->ID, '_edit_last', true) ) {
    		$last_user = get_userdata($last_id);
    		return apply_filters('the_modified_author', $last_user->display_name);
    	}
    }
    function the_modified_author() {
    	echo get_the_modified_author();
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter feisthammel

    (@feisthammel)

    Apologies for the lengthy code. I made a pastebin for get_author_posts_url if needed.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Which action or filter are you applying those functions? Or are you using them in your theme and if so where?

    Thread Starter feisthammel

    (@feisthammel)

    I was trying to plug them into functions.php in a theme built using Boilerplate as a starting point (based in turn on Starkers and TwentyTen).

    The boilerplate_posted_on function is similar to what I was shooting for. My plan was to strip the split archive links and produce the_modified_date followed by the_modified_author as a link to the author archive, just like the one in boilerplate_posted_on function.

    That’s where I run into trouble, because I can’t figure out an elegant way to pull the ID of the modifying author and use it for get_author_posts_url. Basically I want get_the_modified_author_meta and I’m not sure how to make my own in a form that get_author_posts_url will accept as an ID.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    If you look at the original twentyeleven_posted_on(); in content.php you’ll see that it’s located with the loop via

    <?php get_template_part( 'content', get_post_format() ); ?>

    That loads content.php (get_template_part is useful).

    Those functions that you are trying to use should work inside of a loop. Just for experiments sake try your functions inside a loop and confirm if they return results or not.

    Also with a child theme of Twenty Eleven, you can define that function in the child theme’s functions.php file as twentyeleven_posted_on();. You don’t have to rename it because the parent theme’s functions.php checks if the function exists already.

    That may make it easier to debug.

    My PHP skills aren’t that god yet… but did you manage to display the link to the_modified_author like you can do with the function the_author_link?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘the_modified_author URL’ is closed to new replies.