author.php not showing content if Author has no Posts












0














I am making a custom Genesis theme, and have a custom author.php file that pulls in various custom fields (Using Advanced Custom Fields), and author meta information to the page from the author profile page... It also displays their latest posts.



This works perfectly, IF the author has posts assigned to them. If they don't, the page doesn't output any of the content that is normally pulled from the authors profile...



I've searched StackExchange, and whilst this has been mentioned a few times, I can't seem to find an answer that works.



I need the author.php page to output the author information whether the user has posts or not. If they don't, the profile meta and custom fields should still display, and the recent posts section should not show any posts in it.



Here's my author.php code.






// remove Genesis default loop
remove_action( 'genesis_loop', 'genesis_do_loop' );

// Remove Header Markup
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_before_loop', 'genesis_do_author_title_description', 15 );

//remove the default sidebar widget setup
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );

// Add in the layout sections
add_action('genesis_loop','add_top_author_section');
add_action('genesis_sidebar','add_sidebar_info');
add_action('genesis_after_content_sidebar_wrap', 'add_latest_posts');


function add_top_author_section() {
//vars
$avatar = get_avatar( get_the_author_meta( 'ID' ), apply_filters( 'th_author_bio_avatar_size', 300 ) );
$display_name = get_the_author_meta( 'display_name' );
?>
<div class="author-details">
<div class="left-profile">
<?php echo $avatar; ?>
</div>
<div class="right-profile">
<h2><?php echo $display_name; ?></h2>
<p><?php the_author_meta('description'); ?>
</div>
</div>
<?php
}

function add_sidebar_info() {

// Cuisines
$user_id = get_the_author_meta( 'ID' );
$display_id = 'user_'.$user_id;

$terms = get_field('types_of_cuisine2', $display_id);

if ( $terms ) {
echo '<div class="widget-sidebar-section cuisines"><h2>Cuisines</h2>';
foreach ( $terms as $term ) :?>
<a href="http://tastehaus.flywheelsites.com/recipes/?_sfm_cuisine=<?php echo $term; ?>"><?php echo $term; ?></a>

<?php endforeach;
echo '</div>';
}

// Based In
echo '<div class="widget-sidebar-section based-in"><h2>Based In</h2>';
the_field('based_in', $display_id);
echo '</div>';

// Status
echo '<div class="widget-sidebar-section status"><h2>Status</h2>';
the_field('status', $display_id);
echo '</div>';

// Signature Dish
echo '<div class="widget-sidebar-section sig-dish"><h2>Signature Dish</h2>';
the_field('signature_dish', $display_id);
echo '</div>';

// Amazon Store Button
?>
<a href="<?php the_field('amazon_store_link', $display_id);?>"><button>See My Recommended Tools</button> </a>
<?
}


function add_latest_posts() {

echo '<div class="user-latest-posts">';
echo '<h2 style="text-align:center;">Recent Posts by '. get_the_author_meta( 'first_name' ) .'</h2>';
echo '</div>';

global $post;
// arguments, adjust as needed
$args2 = array(
'author' => get_the_author_meta( 'ID' ),
'post_type' => array( 'recipes', 'tools', ),
'orderby' => 'post_date',
'order' => 'ASC',
'posts_per_page' => 6,
);
/*
Overwrite $wp_query with our new query.
The only reason we're doing this is so the pagination functions work,
since they use $wp_query.
*/
global $wp_query;
$wp_query = new WP_Query( $args2 );
if ( have_posts() ) :
echo '<div class="posts-query">';
while ( have_posts() ) : the_post(); ?>
<div class="query-post">
<div class="query-padding">
<div clss="posts-image">
<?php the_post_thumbnail("thumbnail");?>
</div>
<div class="post-categories">
<?php $postType = get_post_type_object(get_post_type());
if ($postType) {
echo esc_html($postType->labels->singular_name);
}
?>
</div>
<div class="posts-title">
<a href="<?php the_permalink(); ?>">
<h3>
<?php the_title() ?>
</h3>
</a>
</div>
</div>
</div>
<? endwhile;
echo '</div>';
do_action( 'genesis_after_endwhile' );
endif;
wp_reset_query();
}
genesis();









share|improve this question



























    0














    I am making a custom Genesis theme, and have a custom author.php file that pulls in various custom fields (Using Advanced Custom Fields), and author meta information to the page from the author profile page... It also displays their latest posts.



    This works perfectly, IF the author has posts assigned to them. If they don't, the page doesn't output any of the content that is normally pulled from the authors profile...



    I've searched StackExchange, and whilst this has been mentioned a few times, I can't seem to find an answer that works.



    I need the author.php page to output the author information whether the user has posts or not. If they don't, the profile meta and custom fields should still display, and the recent posts section should not show any posts in it.



    Here's my author.php code.






    // remove Genesis default loop
    remove_action( 'genesis_loop', 'genesis_do_loop' );

    // Remove Header Markup
    remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
    remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
    remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    remove_action( 'genesis_before_loop', 'genesis_do_author_title_description', 15 );

    //remove the default sidebar widget setup
    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );

    // Add in the layout sections
    add_action('genesis_loop','add_top_author_section');
    add_action('genesis_sidebar','add_sidebar_info');
    add_action('genesis_after_content_sidebar_wrap', 'add_latest_posts');


    function add_top_author_section() {
    //vars
    $avatar = get_avatar( get_the_author_meta( 'ID' ), apply_filters( 'th_author_bio_avatar_size', 300 ) );
    $display_name = get_the_author_meta( 'display_name' );
    ?>
    <div class="author-details">
    <div class="left-profile">
    <?php echo $avatar; ?>
    </div>
    <div class="right-profile">
    <h2><?php echo $display_name; ?></h2>
    <p><?php the_author_meta('description'); ?>
    </div>
    </div>
    <?php
    }

    function add_sidebar_info() {

    // Cuisines
    $user_id = get_the_author_meta( 'ID' );
    $display_id = 'user_'.$user_id;

    $terms = get_field('types_of_cuisine2', $display_id);

    if ( $terms ) {
    echo '<div class="widget-sidebar-section cuisines"><h2>Cuisines</h2>';
    foreach ( $terms as $term ) :?>
    <a href="http://tastehaus.flywheelsites.com/recipes/?_sfm_cuisine=<?php echo $term; ?>"><?php echo $term; ?></a>

    <?php endforeach;
    echo '</div>';
    }

    // Based In
    echo '<div class="widget-sidebar-section based-in"><h2>Based In</h2>';
    the_field('based_in', $display_id);
    echo '</div>';

    // Status
    echo '<div class="widget-sidebar-section status"><h2>Status</h2>';
    the_field('status', $display_id);
    echo '</div>';

    // Signature Dish
    echo '<div class="widget-sidebar-section sig-dish"><h2>Signature Dish</h2>';
    the_field('signature_dish', $display_id);
    echo '</div>';

    // Amazon Store Button
    ?>
    <a href="<?php the_field('amazon_store_link', $display_id);?>"><button>See My Recommended Tools</button> </a>
    <?
    }


    function add_latest_posts() {

    echo '<div class="user-latest-posts">';
    echo '<h2 style="text-align:center;">Recent Posts by '. get_the_author_meta( 'first_name' ) .'</h2>';
    echo '</div>';

    global $post;
    // arguments, adjust as needed
    $args2 = array(
    'author' => get_the_author_meta( 'ID' ),
    'post_type' => array( 'recipes', 'tools', ),
    'orderby' => 'post_date',
    'order' => 'ASC',
    'posts_per_page' => 6,
    );
    /*
    Overwrite $wp_query with our new query.
    The only reason we're doing this is so the pagination functions work,
    since they use $wp_query.
    */
    global $wp_query;
    $wp_query = new WP_Query( $args2 );
    if ( have_posts() ) :
    echo '<div class="posts-query">';
    while ( have_posts() ) : the_post(); ?>
    <div class="query-post">
    <div class="query-padding">
    <div clss="posts-image">
    <?php the_post_thumbnail("thumbnail");?>
    </div>
    <div class="post-categories">
    <?php $postType = get_post_type_object(get_post_type());
    if ($postType) {
    echo esc_html($postType->labels->singular_name);
    }
    ?>
    </div>
    <div class="posts-title">
    <a href="<?php the_permalink(); ?>">
    <h3>
    <?php the_title() ?>
    </h3>
    </a>
    </div>
    </div>
    </div>
    <? endwhile;
    echo '</div>';
    do_action( 'genesis_after_endwhile' );
    endif;
    wp_reset_query();
    }
    genesis();









    share|improve this question

























      0












      0








      0







      I am making a custom Genesis theme, and have a custom author.php file that pulls in various custom fields (Using Advanced Custom Fields), and author meta information to the page from the author profile page... It also displays their latest posts.



      This works perfectly, IF the author has posts assigned to them. If they don't, the page doesn't output any of the content that is normally pulled from the authors profile...



      I've searched StackExchange, and whilst this has been mentioned a few times, I can't seem to find an answer that works.



      I need the author.php page to output the author information whether the user has posts or not. If they don't, the profile meta and custom fields should still display, and the recent posts section should not show any posts in it.



      Here's my author.php code.






      // remove Genesis default loop
      remove_action( 'genesis_loop', 'genesis_do_loop' );

      // Remove Header Markup
      remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
      remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
      remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
      remove_action( 'genesis_before_loop', 'genesis_do_author_title_description', 15 );

      //remove the default sidebar widget setup
      remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
      remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );

      // Add in the layout sections
      add_action('genesis_loop','add_top_author_section');
      add_action('genesis_sidebar','add_sidebar_info');
      add_action('genesis_after_content_sidebar_wrap', 'add_latest_posts');


      function add_top_author_section() {
      //vars
      $avatar = get_avatar( get_the_author_meta( 'ID' ), apply_filters( 'th_author_bio_avatar_size', 300 ) );
      $display_name = get_the_author_meta( 'display_name' );
      ?>
      <div class="author-details">
      <div class="left-profile">
      <?php echo $avatar; ?>
      </div>
      <div class="right-profile">
      <h2><?php echo $display_name; ?></h2>
      <p><?php the_author_meta('description'); ?>
      </div>
      </div>
      <?php
      }

      function add_sidebar_info() {

      // Cuisines
      $user_id = get_the_author_meta( 'ID' );
      $display_id = 'user_'.$user_id;

      $terms = get_field('types_of_cuisine2', $display_id);

      if ( $terms ) {
      echo '<div class="widget-sidebar-section cuisines"><h2>Cuisines</h2>';
      foreach ( $terms as $term ) :?>
      <a href="http://tastehaus.flywheelsites.com/recipes/?_sfm_cuisine=<?php echo $term; ?>"><?php echo $term; ?></a>

      <?php endforeach;
      echo '</div>';
      }

      // Based In
      echo '<div class="widget-sidebar-section based-in"><h2>Based In</h2>';
      the_field('based_in', $display_id);
      echo '</div>';

      // Status
      echo '<div class="widget-sidebar-section status"><h2>Status</h2>';
      the_field('status', $display_id);
      echo '</div>';

      // Signature Dish
      echo '<div class="widget-sidebar-section sig-dish"><h2>Signature Dish</h2>';
      the_field('signature_dish', $display_id);
      echo '</div>';

      // Amazon Store Button
      ?>
      <a href="<?php the_field('amazon_store_link', $display_id);?>"><button>See My Recommended Tools</button> </a>
      <?
      }


      function add_latest_posts() {

      echo '<div class="user-latest-posts">';
      echo '<h2 style="text-align:center;">Recent Posts by '. get_the_author_meta( 'first_name' ) .'</h2>';
      echo '</div>';

      global $post;
      // arguments, adjust as needed
      $args2 = array(
      'author' => get_the_author_meta( 'ID' ),
      'post_type' => array( 'recipes', 'tools', ),
      'orderby' => 'post_date',
      'order' => 'ASC',
      'posts_per_page' => 6,
      );
      /*
      Overwrite $wp_query with our new query.
      The only reason we're doing this is so the pagination functions work,
      since they use $wp_query.
      */
      global $wp_query;
      $wp_query = new WP_Query( $args2 );
      if ( have_posts() ) :
      echo '<div class="posts-query">';
      while ( have_posts() ) : the_post(); ?>
      <div class="query-post">
      <div class="query-padding">
      <div clss="posts-image">
      <?php the_post_thumbnail("thumbnail");?>
      </div>
      <div class="post-categories">
      <?php $postType = get_post_type_object(get_post_type());
      if ($postType) {
      echo esc_html($postType->labels->singular_name);
      }
      ?>
      </div>
      <div class="posts-title">
      <a href="<?php the_permalink(); ?>">
      <h3>
      <?php the_title() ?>
      </h3>
      </a>
      </div>
      </div>
      </div>
      <? endwhile;
      echo '</div>';
      do_action( 'genesis_after_endwhile' );
      endif;
      wp_reset_query();
      }
      genesis();









      share|improve this question













      I am making a custom Genesis theme, and have a custom author.php file that pulls in various custom fields (Using Advanced Custom Fields), and author meta information to the page from the author profile page... It also displays their latest posts.



      This works perfectly, IF the author has posts assigned to them. If they don't, the page doesn't output any of the content that is normally pulled from the authors profile...



      I've searched StackExchange, and whilst this has been mentioned a few times, I can't seem to find an answer that works.



      I need the author.php page to output the author information whether the user has posts or not. If they don't, the profile meta and custom fields should still display, and the recent posts section should not show any posts in it.



      Here's my author.php code.






      // remove Genesis default loop
      remove_action( 'genesis_loop', 'genesis_do_loop' );

      // Remove Header Markup
      remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
      remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
      remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
      remove_action( 'genesis_before_loop', 'genesis_do_author_title_description', 15 );

      //remove the default sidebar widget setup
      remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
      remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );

      // Add in the layout sections
      add_action('genesis_loop','add_top_author_section');
      add_action('genesis_sidebar','add_sidebar_info');
      add_action('genesis_after_content_sidebar_wrap', 'add_latest_posts');


      function add_top_author_section() {
      //vars
      $avatar = get_avatar( get_the_author_meta( 'ID' ), apply_filters( 'th_author_bio_avatar_size', 300 ) );
      $display_name = get_the_author_meta( 'display_name' );
      ?>
      <div class="author-details">
      <div class="left-profile">
      <?php echo $avatar; ?>
      </div>
      <div class="right-profile">
      <h2><?php echo $display_name; ?></h2>
      <p><?php the_author_meta('description'); ?>
      </div>
      </div>
      <?php
      }

      function add_sidebar_info() {

      // Cuisines
      $user_id = get_the_author_meta( 'ID' );
      $display_id = 'user_'.$user_id;

      $terms = get_field('types_of_cuisine2', $display_id);

      if ( $terms ) {
      echo '<div class="widget-sidebar-section cuisines"><h2>Cuisines</h2>';
      foreach ( $terms as $term ) :?>
      <a href="http://tastehaus.flywheelsites.com/recipes/?_sfm_cuisine=<?php echo $term; ?>"><?php echo $term; ?></a>

      <?php endforeach;
      echo '</div>';
      }

      // Based In
      echo '<div class="widget-sidebar-section based-in"><h2>Based In</h2>';
      the_field('based_in', $display_id);
      echo '</div>';

      // Status
      echo '<div class="widget-sidebar-section status"><h2>Status</h2>';
      the_field('status', $display_id);
      echo '</div>';

      // Signature Dish
      echo '<div class="widget-sidebar-section sig-dish"><h2>Signature Dish</h2>';
      the_field('signature_dish', $display_id);
      echo '</div>';

      // Amazon Store Button
      ?>
      <a href="<?php the_field('amazon_store_link', $display_id);?>"><button>See My Recommended Tools</button> </a>
      <?
      }


      function add_latest_posts() {

      echo '<div class="user-latest-posts">';
      echo '<h2 style="text-align:center;">Recent Posts by '. get_the_author_meta( 'first_name' ) .'</h2>';
      echo '</div>';

      global $post;
      // arguments, adjust as needed
      $args2 = array(
      'author' => get_the_author_meta( 'ID' ),
      'post_type' => array( 'recipes', 'tools', ),
      'orderby' => 'post_date',
      'order' => 'ASC',
      'posts_per_page' => 6,
      );
      /*
      Overwrite $wp_query with our new query.
      The only reason we're doing this is so the pagination functions work,
      since they use $wp_query.
      */
      global $wp_query;
      $wp_query = new WP_Query( $args2 );
      if ( have_posts() ) :
      echo '<div class="posts-query">';
      while ( have_posts() ) : the_post(); ?>
      <div class="query-post">
      <div class="query-padding">
      <div clss="posts-image">
      <?php the_post_thumbnail("thumbnail");?>
      </div>
      <div class="post-categories">
      <?php $postType = get_post_type_object(get_post_type());
      if ($postType) {
      echo esc_html($postType->labels->singular_name);
      }
      ?>
      </div>
      <div class="posts-title">
      <a href="<?php the_permalink(); ?>">
      <h3>
      <?php the_title() ?>
      </h3>
      </a>
      </div>
      </div>
      </div>
      <? endwhile;
      echo '</div>';
      do_action( 'genesis_after_endwhile' );
      endif;
      wp_reset_query();
      }
      genesis();






      wordpress wordpress-theming custom-wordpress-pages genesis author






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 19:01









      user2115227user2115227

      60110




      60110
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451801%2fauthor-php-not-showing-content-if-author-has-no-posts%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451801%2fauthor-php-not-showing-content-if-author-has-no-posts%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks