Title: gpcola's Replies | WordPress.org

---

# gpcola

  [  ](https://wordpress.org/support/users/gpcola/)

 *   [Profile](https://wordpress.org/support/users/gpcola/)
 *   [Topics Started](https://wordpress.org/support/users/gpcola/topics/)
 *   [Replies Created](https://wordpress.org/support/users/gpcola/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/gpcola/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/gpcola/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/gpcola/engagements/)
 *   [Favorites](https://wordpress.org/support/users/gpcola/favorites/)

 Search replies:

## Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)

 *   Forum: [Reviews](https://wordpress.org/support/forum/reviews/)
    In reply to:
   [[Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization] Works, but with a GOTCHA that made it useless for me](https://wordpress.org/support/topic/works-but-with-a-gotcha-that-made-it-useless-for-me/)
 *  [gpcola](https://wordpress.org/support/users/gpcola/)
 * (@gpcola)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/works-but-with-a-gotcha-that-made-it-useless-for-me/#post-15940612)
 * Optimole will lazy load _all_ images on a page if configured to do so, and it
   makes no distinction between ‘header’ and body images when it processes output
   sizing.
 * It’s great that you found a solution that satisfies your need, but I think Optimole
   could have solved the issue too if the right settings had been applied 😉
 *   Forum: [Reviews](https://wordpress.org/support/forum/reviews/)
    In reply to:
   [[Advanced Shipment Tracking for WooCommerce] Removed updated tracking option from free version](https://wordpress.org/support/topic/removed-updated-tracking-option-from-free-version/)
 *  [gpcola](https://wordpress.org/support/users/gpcola/)
 * (@gpcola)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/removed-updated-tracking-option-from-free-version/#post-14705847)
 * This is the normal development cycle for free software. You test it for free,
   then they charge others to use what you tested. You don’t have to update to the
   new version, but then a 9/10 security issue is announced, leaving you with no
   choice 😀
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Custom Content Type Manager] in_array() expects parameter 2 to be array, null given (nav-menu-template.php)](https://wordpress.org/support/topic/n_array-expects-parameter-2-to-be-array-null-given-nav-menu-templatephp/)
 *  Thread Starter [gpcola](https://wordpress.org/support/users/gpcola/)
 * (@gpcola)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/n_array-expects-parameter-2-to-be-array-null-given-nav-menu-templatephp/#post-4143973)
 * To update my question with what looks like pertinent information following [discussion on SO](http://stackoverflow.com/questions/18899283/custom-archive-page-causing-error-in-nav-menu-template-php):
 * The custom post type in question is heirarchical and posts are being assigned
   a parent of another custom post type. I tried removing the link but it didn’t
   help.
 * The capability type is set to default of ‘post’. I tried setting to ‘page’ but
   it didn’t help.
 * It was suggested to print_r($queried_object); right before line 440 and here 
   is the resulting output – note that there is no ‘ancestor’ in the object
 * > stdClass Object ( [labels] => stdClass Object ( [name] => Vehicles [singular_name]
   > => Vehicle [add_new] => Add New [add_new_item] => Add New Vehicle [edit_item]
   > => Edit Vehicle [new_item] => New Vehicle [view_item] => View Vehicle [search_items]
   > => Search Vehicles [not_found] => No Vehicles Found [not_found_in_trash] =>
   > No Vehicles found in Trash [parent_item_colon] => Operator [all_items] => Vehicles[
   > menu_name] => Vehicles [name_admin_bar] => Vehicle ) [description] => Each 
   > vehicle is linked to an Operator [publicly_queryable] => 1 [exclude_from_search]
   > => [capability_type] => post [map_meta_cap] => 1 [_builtin] => [_edit_link]
   > => post.php?post=%d [hierarchical] => 1 [public] => 1 [rewrite] => Array ( [
   > slug] => vehicle [with_front] => 1 [pages] => 1 [feeds] => 1 [ep_mask] => 1)[
   > has_archive] => 1 [query_var] => [register_meta_box_cb] => [taxonomies] => 
   > Array ( [0] => category [1] => features [2] => colours [3] => drivers ) [show_ui]
   > => 1 [menu_position] => [menu_icon] => [can_export] => 1 [show_in_nav_menus]
   > => 1 [show_in_menu] => 1 [show_in_admin_bar] => 1 [delete_with_user] => [cctm_hierarchical_custom]
   > => 1 [cctm_hierarchical_includes_drafts] => [cctm_hierarchical_post_types] 
   > => Array ( [0] => operator ) [cctm_custom_columns_enabled] => 0 [post_type]
   > => vehicle [use_default_menu_icon] => 1 [label] => Vehicles [cctm_show_in_menu]
   > => 1 [cctm_show_in_menu_custom] => [rewrite_with_front] => 1 [permalink_action]
   > => /%postname%/ [rewrite_slug] => [include_in_search] => 1 [include_in_rss]
   > => 1 [cctm_enable_right_now] => 1 [custom_order] => ASC [is_active] => 1 [custom_fields]
   > => Array ( [0] => passenger_capacity [1] => luggage_capacity [2] => hourly_rate[
   > 3] => included_milleage [4] => additional_mileage_price [5] => additional_image)[
   > map_field_metabox] => Array ( [passenger_capacity] => cctm_vehicledetails [
   > luggage_capacity] => cctm_vehicledetails [hourly_rate] => cctm_vehicledetails[
   > included_milleage] => cctm_vehicledetails [additional_mileage_price] => cctm_vehicledetails[
   > additional_image] => cctm_default ) [original_post_type_name] => vehicle [name]
   > => vehicle [cap] => stdClass Object ( [edit_post] => edit_post [read_post] 
   > => read_post [delete_post] => delete_post [edit_posts] => edit_posts [edit_others_posts]
   > => edit_others_posts [publish_posts] => publish_posts [read_private_posts] 
   > => read_private_posts [read] => read [delete_posts] => delete_posts [delete_private_posts]
   > => delete_private_posts [delete_published_posts] => delete_published_posts [
   > delete_others_posts] => delete_others_posts [edit_private_posts] => edit_private_posts[
   > edit_published_posts] => edit_published_posts [create_posts] => edit_posts ))
   > stdClass Object ( [labels] => stdClass Object ( [name] => Vehicles [singular_name]
   > => Vehicle [add_new] => Add New [add_new_item] => Add New Vehicle [edit_item]
   > => Edit Vehicle [new_item] => New Vehicle [view_item] => View Vehicle [search_items]
   > => Search Vehicles [not_found] => No Vehicles Found [not_found_in_trash] =>
   > No Vehicles found in Trash [parent_item_colon] => Operator [all_items] => Vehicles[
   > menu_name] => Vehicles [name_admin_bar] => Vehicle ) [description] => Each 
   > vehicle is linked to an Operator [publicly_queryable] => 1 [exclude_from_search]
   > => [capability_type] => post [map_meta_cap] => 1 [_builtin] => [_edit_link]
   > => post.php?post=%d [hierarchical] => 1 [public] => 1 [rewrite] => Array ( [
   > slug] => vehicle [with_front] => 1 [pages] => 1 [feeds] => 1 [ep_mask] => 1)[
   > has_archive] => 1 [query_var] => [register_meta_box_cb] => [taxonomies] => 
   > Array ( [0] => category [1] => features [2] => colours [3] => drivers ) [show_ui]
   > => 1 [menu_position] => [menu_icon] => [can_export] => 1 [show_in_nav_menus]
   > => 1 [show_in_menu] => 1 [show_in_admin_bar] => 1 [delete_with_user] => [cctm_hierarchical_custom]
   > => 1 [cctm_hierarchical_includes_drafts] => [cctm_hierarchical_post_types] 
   > => Array ( [0] => operator ) [cctm_custom_columns_enabled] => 0 [post_type]
   > => vehicle [use_default_menu_icon] => 1 [label] => Vehicles [cctm_show_in_menu]
   > => 1 [cctm_show_in_menu_custom] => [rewrite_with_front] => 1 [permalink_action]
   > => /%postname%/ [rewrite_slug] => [include_in_search] => 1 [include_in_rss]
   > => 1 [cctm_enable_right_now] => 1 [custom_order] => ASC [is_active] => 1 [custom_fields]
   > => Array ( [0] => passenger_capacity [1] => luggage_capacity [2] => hourly_rate[
   > 3] => included_milleage [4] => additional_mileage_price [5] => additional_image)[
   > map_field_metabox] => Array ( [passenger_capacity] => cctm_vehicledetails [
   > luggage_capacity] => cctm_vehicledetails [hourly_rate] => cctm_vehicledetails[
   > included_milleage] => cctm_vehicledetails [additional_mileage_price] => cctm_vehicledetails[
   > additional_image] => cctm_default ) [original_post_type_name] => vehicle [name]
   > => vehicle [cap] => stdClass Object ( [edit_post] => edit_post [read_post] 
   > => read_post [delete_post] => delete_post [edit_posts] => edit_posts [edit_others_posts]
   > => edit_others_posts [publish_posts] => publish_posts [read_private_posts] 
   > => read_private_posts [read] => read [delete_posts] => delete_posts [delete_private_posts]
   > => delete_private_posts [delete_published_posts] => delete_published_posts [
   > delete_others_posts] => delete_others_posts [edit_private_posts] => edit_private_posts[
   > edit_published_posts] => edit_published_posts [create_posts] => edit_posts ))
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How can I display a random comment from a PAGE on my site on home?](https://wordpress.org/support/topic/how-can-i-display-a-random-comment-from-a-page-on-my-site-on-home/)
 *  Thread Starter [gpcola](https://wordpress.org/support/users/gpcola/)
 * (@gpcola)
 * [16 years ago](https://wordpress.org/support/topic/how-can-i-display-a-random-comment-from-a-page-on-my-site-on-home/#post-1556009)
 * et voilà!
 *     ```
       // display a random comment
       function randomComment_handler($post_id) {
       	extract( shortcode_atts( array(
       		'post_id' => '0',
       		), $atts ) );
       	$out = "";
       	$comments = get_comments("post_id=$post_id&status=approve");
       	if ($comments) {
       		$ndx = mt_rand(1,sizeof($comments)) - 1;
       		$comment = $comments[$ndx];
       		$out = "<div><div class='comment_wrapper'><div class='comment_author'>".$comment->comment_author."</div><div class='comment_content'>".$comment->comment_content."</div></div><div class='cleared'></div></div>";
       	}
       	return $out;
       }
       add_shortcode('randomComment', 'randomComment_handler');
       ```
   
 * now I only need to add this to my page/posts to display a random comment:
 *     ```
       [randomComment post_id="11"]
       ```
   
 * vtxyzzy you have been more than helpful! Thank you!
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How can I display a random comment from a PAGE on my site on home?](https://wordpress.org/support/topic/how-can-i-display-a-random-comment-from-a-page-on-my-site-on-home/)
 *  Thread Starter [gpcola](https://wordpress.org/support/users/gpcola/)
 * (@gpcola)
 * [16 years ago](https://wordpress.org/support/topic/how-can-i-display-a-random-comment-from-a-page-on-my-site-on-home/#post-1555994)
 * Aha! Now that looks like it would fly!
 * Thanks again vtxyzzy – being new to WordPress I don’t really know what functionality
   I have available to me by default so using a plugin seemed like the obvious choice
   but looking at how shortcodes work it looks like I can eliminate that extra overhead
   and use what wordpress provides as standard 🙂
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How can I display a random comment from a PAGE on my site on home?](https://wordpress.org/support/topic/how-can-i-display-a-random-comment-from-a-page-on-my-site-on-home/)
 *  Thread Starter [gpcola](https://wordpress.org/support/users/gpcola/)
 * (@gpcola)
 * [16 years ago](https://wordpress.org/support/topic/how-can-i-display-a-random-comment-from-a-page-on-my-site-on-home/#post-1555975)
 * After playing around a little more I was able to use the inline-php plugin I 
   wanted to use originally. By modifying my template code and outputting the comment
   and author to vars like so:
 *     ```
       <?php
       /*
       Template Name: simple
       */
       ?>
       <?php get_header(); ?>
   
       <div class="art-contentLayout-home">
         <div class="art-content">
           <?php if (have_posts()) : ?>
           <?php while (have_posts()) : the_post(); ?>
           <div class="art-Post">
             <div class="art-Post-body">
               <div class="art-Post-inner art-article">
                 <div class="art-PostContent">
       <?php
       $theAuthor="";
       $theComment="";
       $post_id = 11;  // Put the 'testimonials' id here
       $comments = get_comments("post_id=$post_id&status=approve");
       if ($comments) {
       	$ndx = mt_rand(1,sizeof($comments)) - 1;
       	$comment = $comments[$ndx];
       	$theAuthor=$comment->comment_author;
       	$theComment=$comment->comment_content;
       }
       ?>
                   <?php remove_filter ('the_content', 'wpautop'); ?>
                   <?php the_content(); ?>
                 </div>
               </div>
             </div>
           </div>
           <?php endwhile; ?>
           <?php endif; ?>
         </div>
         <div class="cleared"></div>
       </div>
       <?php get_footer(); ?>
       ```
   
 * I was then able to reference them in the_content() like so:
 *     ```
       <div class='comment_wrapper'>
             <div class='comment_author'>
               <?php global $theAuthor, $theComment; ?>
               <?php echo $theAuthor; ?>
             </div>
             <div class='comment_content'>
               <?php echo $theComment; ?>
             </div>
           </div>
           <div class="cleared"></div>
         </div>
       ```
   
 * 😉
 * This makes it a little easier for me and any other editors to redesign the home
   page later on.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How can I display a random comment from a PAGE on my site on home?](https://wordpress.org/support/topic/how-can-i-display-a-random-comment-from-a-page-on-my-site-on-home/)
 *  Thread Starter [gpcola](https://wordpress.org/support/users/gpcola/)
 * (@gpcola)
 * [16 years ago](https://wordpress.org/support/topic/how-can-i-display-a-random-comment-from-a-page-on-my-site-on-home/#post-1555944)
 * Excellent! Your code snippet was exactly what I needed 😉 Creating a new template
   for the home page wasn’t a problem so all I needed to do was cut and paste your
   code, bar the addition of a missing ‘?>’.
 * Thank you for your swift response vtxyzzy!
 * My template code is now as follows:
 *     ```
       <?php
       /*
       Template Name: simple
       */
       ?>
       <?php get_header(); ?>
   
       <div class="art-contentLayout-home">
         <div class="content">
           <?php if (have_posts()) : ?>
           <?php while (have_posts()) : the_post(); ?>
           <div class="post">
             <div class="post-body">
               <div class="post-inner art-article">
                 <div class="postContent">
                   <div>
                     <div><img src="..." width="304" height="141" alt="" />
                       <?php
       $post_id = 11;  // Put the 'testimonials' id here
       $comments = get_comments("post_id=$post_id&status=approve");
       if ($comments) {
        $ndx = mt_rand(1,sizeof($comments)) - 1;
        $comment = $comments[$ndx];
        ?>
                       <div class='comment_wrapper'>
                         <div class='comment_author'> <?php echo "Comment By:$comment->comment_author"; ?> </div>
                         <div class='comment_content'> <?php echo $comment->comment_content; ?> </div>
                       </div>
                       <?php } ?>
                       <div class="cleared"></div>
                     </div>
                     <?php remove_filter ('the_content', 'wpautop'); ?>
                     <?php the_content(); ?>
                   </div>
                 </div>
               </div>
             </div>
           </div>
           <?php endwhile; ?>
           <?php endif; ?>
         </div>
         <div class="cleared"></div>
       </div>
       <?php get_footer(); ?>
       ```
   

Viewing 7 replies - 1 through 7 (of 7 total)