0

I'm working on a site which requires requires users to submit a custom profile of sorts, and then one post in a specific category (all of that is being done through Gravity Forms and their User Registration add on).

I then need to display that post with the user's profile which is being displayed at the top of single posts and archives (because that one post is being used in conjunction with a voting plugin...so whenever someone views any post written by that author, they're also viewing that author's profile and entry post, which includes the voting button).

First, I've got this on customizing the author box: http://www.billerickson.net/code/customize-author-box/

and this is the entirety of what I need to display with the author profile (here it in pastie, I keep trying to get it all in correctly here: http://pastie.org/5379532 ):

<!-- This sets the $curauth variable -->
<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) :    get_userdata(intval($author));
?> 
<div id="contestants"> 
<!-- The Loop -->
<?php query_posts('category_name=contestants&posts_per_page=1'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<h2><?php echo $curauth->user_nicename; ?></h2>
<?php the_post_thumbnail('medium', array('class' => 'alignleft')); ?>
<?php act_last_connect($author) ?></br>
<?php if(function_exists('getvote5')) getvote5('get'); ?></br>
<h2>About Me</h2>
Posted: <?php the_time('M. d, Y'); ?>
     <?php the_content(); ?>

<?php endwhile; else: ?>
    <p><?php _e('This contestant has not created his/her entry.'); ?></p>
<?php endif; ?>

<!-- End Loop -->
</div>

But from here, I don't really know how to merge the example from Bill and what I have. Can someone help me understand?

4
  • Please work on your old questions. That's part of the game.
    – kaiser
    Commented Nov 14, 2012 at 17:01
  • I went back and marked the answers as accepted. Is that what you mean? Commented Nov 14, 2012 at 20:28
  • If you revised the comments left and in need of reply, and marked the "correct" answers as accepted, then I think yes, that was what @kaiser meant :) ...... Regarding your Q, it seems that the code you posted is not enough to draw any conclusion. How that endwhile begun? What's the use of the function act_last_connect?
    – brasofilo
    Commented Nov 14, 2012 at 21:10
  • The act_last_connect works to display the last time the user logged in (it works with a plugin installed). The second bit of code didn't paste completely. I edited it - see if it makes more sense. Commented Nov 14, 2012 at 22:34

1 Answer 1

0

WOO WOO! I got it! I'm using a custom theme for Genesis, so you may see some of that in the notes below, but here it is in case anyone wants to see it.

In functions.php

/** Display author box on single posts */
add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );

/** Display author box on archive pages */
add_filter( 'get_the_author_genesis_author_box_archive', '__return_true' );

/** Removes author box after posts */
remove_action('genesis_after_post', 'genesis_do_author_box_single');

/** Adds author box before content */
add_action('genesis_before_post', 'genesis_do_author_box_single');
add_action( 'genesis_before_loop', 'include_contestants_entry' ); 
function include_contestants_entry() { 
if( is_single() ) {
require(CHILD_DIR.'/contestants_entry.php');    
}
}

/** Replace the standard loop with our custom loop */
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'child_do_custom_loop' );

function child_do_custom_loop() {

global $paged; // current paginated page
global $query_args; // grab the current wp_query() args
$args = array(
    'category__not_in' => 7, // exclude posts from this category
    'paged'            => $paged, // respect pagination
);

genesis_custom_loop( wp_parse_args($query_args, $args) );

}

And then contestants_entry.php

<!-- This sets the $curauth variable -->

<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) :       get_userdata(intval($author));
?> 
<div id="contestants"> 
<!-- The Loop -->
<?php query_posts('category_name=contestants&posts_per_page=1'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<h2><?php echo $curauth->user_nicename; ?></h2>
    <?php the_post_thumbnail('medium', array('class' => 'alignleft')); ?>
    <?php act_last_connect($author) ?></br>
    <?php if(function_exists('getvote5')) getvote5('get'); ?></br>
    <h2>About Me</h2>
    Posted: <?php the_time('M. d, Y'); ?>
     <?php the_content(); ?>

<?php endwhile; else: ?>
    <p><?php _e('This contestant has not created his/her entry.'); ?></p>
<?php endif; ?>

I still have to go back and add some of the custom fields that were created in the user registration process (into contestants_entry.php) but I'll get it.

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.