0

Now what I need to find a solution of is this issue:

I have 8 authors, and a bunch of posts. All authors have there own adsense (or other affiliate), we wish to show the adds belongings to the authors on there OWN posts.

So the author collects payment (if any) from there own posts, and only from there own posts.

Is there any way to make wordpress/theme do something like that?

Thanks Marius

2
  • 1
    You have the information who the post author is, so having a post type per author shouldn't be necessary. Commented Dec 5, 2013 at 13:30
  • Oh.. So what you are saying is that it IS possible for at post (from a guest view) to look "different" from author to author?? Commented Dec 5, 2013 at 19:43

2 Answers 2

1

You don't say how you have set up the different adsense. I will assume that in your template there is a folder, called 'authors-ads', in it you have some php files, named after your authors ids, e.g.:

  • /authors-ads/author-1.php
  • /authors-ads/author-12.php

and so on.

after that in your single.php or whatever template you use to display posts

use

global $post;
get_template_part('authors-ads/author', $post->post_author );

in this way the file related to the post author is included in the page.

In that file put the ads related to the author, of course.

1
  • Yeah.. That sounds to be the easy way, I will try that out. Thanks alot.... Commented Dec 6, 2013 at 10:12
1

Spawning multiple custom post types for authors is not their typical usage and would likely have too many unwanted implications.

It is pretty easy to retrieve info for the author of the post in template file (see get_the_author_meta() for example) and use it to conditionally output necessary individual data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.