WordPress automatically attributes posts to authors, and I wanted to know how to ensure that when somebody write a portfolio entry, that that portfolio entry is attributed to them. In other words to make sure that portfolio pages endup in domain/authorname/
Based on: http://wordpress.stackexchange.com/questions/11210/including-post-type-wiki-in-author-archives I’d try to add following function to functions.php:
function inoplugs_portfolio_for_author( &$query )
if ( $query->is_author )
$query->set( 'post_type', 'portfolio' );
remove_action( 'pre_get_posts', 'inoplugs_portfolio_for_author' ); // run once!
add_action( 'pre_get_posts', 'inoplugs_portfolio_for_author' );
This worked beautifully. Thank you so much for your help!
I have been asking a lot of questions as of late. Is there any way that I can donate more $?
I tried to use this solution on the newer versions of WordPress / Angular and it wouldn’t work, but I found another way to make this happen. In the file, register-portfolio.php located in /includes/admin, I went to the following lines of code:
$args = array(
‘labels’ => $labels,
‘public’ => true,
‘show_ui’ => true,
‘capability_type’ => ‘post’,
‘hierarchical’ => false,
‘rewrite’ => array(‘slug’=>$slugRule,’with_front’=>true),
‘query_var’ => true,
‘supports’ => array(‘title’,'thumbnail’,'excerpt’,'editor’,'comments’)
I changed the final line to read:
‘supports’ => array(‘title’,'thumbnail’,'excerpt’,'editor’,'comments’,'author’)
Maybe this will be useful to others!
The topic ‘Authorship and Profiles’ is closed to new replies.