-
The theme I use (Enfold) comes with a multi-author blog page with gravatars. Gravatars produced through UserPro work nicely on that page. However, UserPro permalinks don’t, so, for example, if I do a 301 redirect from author.php to the UserPro’s profile page, the links may or may not work, regardless of the type of permalink (e.g., username, full name, user ID) I choose. One problem is the period (dot) in usernames from a social network (which most any author.php converts to a dash). I’ve tried different combinations, and nothing works consistently.
So I’m thinking that a good alternative would be to try to link from just one element–the gravatar–in the output from the theme author.php file to the author’s profile page produced by UserPro. I’d think that’s be something easy for a programmer, but I’m not a programmer. How to make this work? I would assume I’d add some filter to my functions.php file, but what and where?
I’m attaching my theme’s author.php file in the event someone knows how to accomplish this. I’ve been trying to get the blog to connect correctly to UserPro on and off for a month now without success, so any hints are welcome.
Thanks.
PHP1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859?phpglobal $avia_config, $more;/** get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.*/get_header();$description = is_tag() ? tag_description() : category_description();echo avia_title(array('title' => avia_which_archive(), 'subtitle' => $description, 'link'=>false));$author_id = get_query_var( 'author' );$name = apply_filters('avf_author_name', get_the_author_meta('display_name', $author_id), $author_id);$heading_s = __("Entries by",'avia_framework') ." ".$name;?><div class='container_wrap container_wrap_first main_color <?php avia_layout_class( 'main' ); ?>'><div class='container template-blog template-author '><main class='content <?php avia_layout_class( 'content' ); ?> units' <?php avia_markup_helper(array('context' => 'content'));?>><div class='page-heading-container clearfix'><?phpget_template_part( 'includes/loop', 'about-author' );?></div><?phpecho "<h4 class='extra-mini-title widgettitle'>{$heading_s}</h4>";/* Run the loop to output the posts.* If you want to overload this in a child theme then include a file* called loop-index.php and that will be used instead.*/$more = 0;get_template_part( 'includes/loop', 'author' );?><!--end content--></main><?php//get the sidebar$avia_config['currently_viewing'] = 'blog';get_sidebar();?></div><!--end container--></div><!-- close default .container_wrap element --><?php get_footer(); ?>And this is the loop-author.php page:
PHP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142?phpglobal $avia_config, $post_loop_count;if(empty($post_loop_count)) $post_loop_count = 1;$blog_style = avia_get_option('blog_style','multi-big');// check if we got posts to display:if (have_posts()) :while (have_posts()) : the_post();/** get the current post id, the current post class and current post format*/$current_post = array();$current_post['post_loop_count'] = $post_loop_count;$current_post['the_id'] = get_the_ID();$current_post['parity'] = $post_loop_count % 2 ? 'odd' : 'even';$current_post['last'] = count($wp_query->posts) == $post_loop_count ? " post-entry-last " : "";$current_post['post_class'] = "post-entry-".$current_post['the_id']." post-loop-".$post_loop_count." post-parity-".$current_post['parity'].$current_post['last']." ".$blog_style;$current_post['post_format'] = get_post_format() ? get_post_format() : 'standard';/** retrieve slider, title and content for this post,...*/$size = strpos($blog_style, 'big') ? strpos(avia_layout_class( 'main' , false), 'sidebar') ? 'entry_with_sidebar' : 'entry_without_sidebar' : 'square';$current_post['slider'] = get_the_post_thumbnail($current_post['the_id'], $size);$current_post['title'] = get_the_title();$current_post['content'] = get_the_excerpt();$with_slider = empty($current_post['slider']) ? "" : "with-slider";/** ...now apply a filter, based on the post type... (filter function is located in includes/helper-post-format.php)*/$current_post = apply_filters( 'post-format-'.$current_post['post_format'], $current_post );/** ... last apply the default wordpress filters to the content*/$current_post['content'] = str_replace(']]>', ']]>', apply_filters('the_content', $current_post['content'] ));/** Now extract the variables so that $current_post['slider'] becomes $slider, $current_post['title'] becomes $title, etc*/extract($current_post);/** render the html:*/?><article <?php post_class('post-entry post-entry-type-'.$post_format . " " . $post_class . " ".$with_slider); ?>' <?php avia_markup_helper(array('context' => 'entry')); ?>><div class="entry-content-wrapper clearfix <?php echo $post_format; ?>-content"><header class="entry-content-header"><?php//echo the post titleecho $title;?><span class='post-meta-infos'><span class='date-container minor-meta updated'><?php the_time(get_option('date_format')); ?></span><?php if ( get_comments_number() != "0" || comments_open() ){echo "<span class='text-sep'>/</span>";echo "<span class='comment-container minor-meta'>";comments_popup_link( "0 ".__('Comments','avia_framework'),"1 ".__('Comment' ,'avia_framework'),"% ".__('Comments','avia_framework'),'comments-link',"".__('Comments Disabled','avia_framework'));echo "</span>";}$taxonomies = get_object_taxonomies(get_post_type($the_id));$cats = '';$excluded_taxonomies = apply_filters('avf_exclude_taxonomies', array('post_tag','post_format'), get_post_type($the_id), $the_id);if(!empty($taxonomies)){foreach($taxonomies as $taxonomy){if(!in_array($taxonomy, $excluded_taxonomies)){$cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';}}}if(!empty($cats)){echo "<span class='text-sep'>/</span>";echo '<span class="blog-categories minor-meta">'.__('in','avia_framework')." ";echo $cats;echo '</span>';}?></span></header><?php// echo the post contentecho '<div class="entry-content"'.avia_markup_helper(array('context' => 'entry_content','echo'=>false)).'>';echo wpautop($content);echo '</div>';?></div><footer class="entry-footer"></footer></article><!--end post-entry--><?php$post_loop_count++;endwhile;else:?><article class="entry"><header class="entry-content-header"><h1 class='post-title entry-title'><?php _e('Nothing Found', 'avia_framework'); ?></h1></header><p class="entry-content" <?php avia_markup_helper(array('context' => 'entry_content')); ?>><?php _e('Sorry, no posts matched your criteria', 'avia_framework'); ?></p><footer class="entry-footer"></footer></article><?phpendif;if(!isset($avia_config['remove_pagination'] )){echo avia_pagination('', 'nav');// paginate_links(); posts_nav_link(); next_posts_link(); previous_posts_link();}?By the way, if getting UserPro to work with a theme’s blog is “custom” work, I’d certainly be willing to pay to get it working correctly and consistently. Thanks.
Hi Ahmed. It’ll be more clear–I hope–when seen in action. For the moment, I’m going to use the Enfold demo, as I haven’t changed a thing from the theme’s default coding (and my site is not yet ready).
Here’s the blog page. Note that the avatar is a feature of the theme. UserPro’s profile photo replaces this perfectly. So far so good.
Click on the profile photo or author name and you get the output of author.php for that author.
http://www.kriesi.at/themes/enfold/author/kriesi/
What I’m trying to do is to link the profile pic (avatar) on this page (i.e., within author.php) to the author’s full profile on the UserPro profile page. That’s about it.
One reason I’m trying to do this is because linking from the blog directly (using a 301 redirect from author.php to /profile) to UserPro doesn’t work for some of the users some of the time because the permalinks either work only with names with no periods in them or with names with periods–bot not both.
Thanks.
To clarify: The permalink structure on UP’s global settings do not work on this particular theme’s author page because the UP settings do not override the default theme setting in this instance, which is username. So, for example, if I change permalinks to User ID, the author page will still use username. Even if I use username in the UP settings, all usernames with periods in them (Facebook names, for example) will not direct to the UP profile page because a hyphen (dash) replaces the period. In other words, it’s not a UserPro problem by itself. Rather, it’s the combination of UP and this theme.
That’s one reason I’m asking how the UP profile can be linked to from the author page.
I sat the whole day today with a similar problem, but in my case, the author is a custom post type “agent” , resulting in permalink to be /agent whereas Userpro link is /profile, so I went into the post type functions and changed the slug from “agent” to “profile”.
So I changed this:
'rewrite' => array( 'slug' => __('agent')
To this:
'rewrite' => array( 'slug' => __('profile')
I also added support for author to my custom post type as “author” was not supported.
'supports' => array('author','title','editor','thumbnail'),
This solved my permalink problem. I then had to find a way to display the rest of the “agent” page content on the USERPRO profile page, so I edited the “postbyuser” template and added my “agent” page php code inside it and then used short code for postbyuser on profile page. This results in content from my original agent page, now diplaying perfect on the Userpro Profile page. So I basically now use postbyuser template to display all the “author page content”.
Perhaps your theme is also using a custom post type for the authors, if so then the above code change will maybe help you solve your problem, else adding your author.php file content to postbyuser template, might solve your problem.
Hi Enigma. Thanks for trying to help–I appreciate it. What you say makes sense; unfortunately, the theme I’m using does not use a CPT for authors (in other words, it’s WordPress default as far as that part is concerned). I actually do think it’s something quite simple, but I just can’t see it.
I found this code, it might help: (wish I found it earlier, after sitting for hours on end editing code…lol)
function change_author_permalinks() {
global $wp_rewrite;
// Change the value of the author permalink base to whatever you want here
$wp_rewrite->author_base = 'profile';
$wp_rewrite->flush_rules();
}add_action('init','change_author_permalinks')
`
Thanks. That looked pretty much the same as a htaccess redirect (i.e., changing /author to /profile), but I tried it and with the same result. For whatever reason, the UserPro permalink option isn’t working for me in the author section, so even if author is set to profile, I still have the same problem. The theme authors can’t help because the theme actually adds nothing to the author’s name. So, I’m pretty much stuck if I can’t get UserPro to work with the author page. I’m not at all saying that either the theme or the plugin is at fault; for all I know, I could be doing something wrong. But I’m glad it worked for you, and thanks again.
You must be logged in to reply to this topic.