I am running the really-simple-facebook-twitter-share-buttons. I have placed the below code on my site as the plug in recommends, which is:
<div class="share"><?php echo really_simple_share_publish();?></div>
This plugin is working on all of my site, except I have a custom taxonomy page that is causing the following error with the plugin:
Notice: Trying to get property of non-object in /home3/answr/public_html/wp-includes/post-template.php on line 29
I have reviewed line 29 and here is what I think is happening.
My taxonomy page has two main custom queries built into it and two wordpress loops. These queries modify the main wordpress query for the page.
It seems if the first query does not return results then it causes the error above if the plugin is active.
However, if the first query returns results then there is no error and the plugin works fine even if the second query returns results.
And if the plugin is not active I get no error whether the first query returns results or not.
Here is my code for reference. I have been trying to solve this for some time and I am out of ideas. Does anyone have ideas what could be causing this issues or what I should try to solve it. Thank you!
<?php
query_single('dealers', 'publish', '1', $taxtype, $value);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$address=get_post_meta($post->ID, 'wpcf-street_address', TRUE);
$city=get_post_meta($post->ID, 'wpcf-city', TRUE);
$state=get_post_meta($post->ID, 'wpcf-state_abbreviation', TRUE);
$zip=get_post_meta($post->ID, 'wpcf-zip_code', TRUE);
$phone=get_post_meta($post->ID, 'wpcf-phone_number', TRUE);
$paid=get_post_meta($post->ID, 'wpcf-paid', TRUE);
$post_id=get_the_ID();
get_each_dealer_brand($post_id);?>
<?php
echo "<ul class=\"ullisting\">";
if($paid==1)
{
echo "<li><p class=\"plisting\"><strong><a href=\"";the_permalink(); echo "\">";the_title();echo "</a></strong></p></li>";
echo "<li><p class=\"plisting\">$address | $city, $state $zip</p></li>";
echo "<li><p class=\"plisting\">P: $phone</p></li>";
echo "<li><p class=\"listing\"><span><small>$brands_list</small></span></p></li>";
}
echo "</ul>";
?>
<?php endwhile; ?>
<?php
wp_reset_query();
wp_reset_postdata();
unset($brands_list);
?>
<?php else : ?>
<?php
$paidnull="true";
?>
<?php endif; ?>
<?php
query_single('dealers', 'draft', '0', $taxtype, $value);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php $address=get_post_meta($post->ID, 'wpcf-street_address', TRUE);
$city=get_post_meta($post->ID, 'wpcf-city', TRUE);
$state=get_post_meta($post->ID, 'wpcf-state_abbreviation', TRUE);
$zip=get_post_meta($post->ID, 'wpcf-zip_code', TRUE);
$phone=get_post_meta($post->ID, 'wpcf-phone_number', TRUE);
$paid=get_post_meta($post->ID, 'wpcf-paid', TRUE);
$post_id=get_the_ID();
get_each_dealer_brand($post_id);
?>
<?php
echo "<ul class=\"ullisting\">";
if($paid==0){
echo "<li><p class=\"plisting\"><strong>";the_title();echo "</strong></p></li>";
echo "<li><p class=\"plisting\">$address | $city, $state $zip</p></li>";
echo "<li><p class=\"plisting\">P: $phone</p></li>";
echo "<li><p class=\"listing\"><span><small>$brands_list</small></span></p></li>";
}
echo "</ul>";
?>
<?php endwhile; ?>
<?php /*Resets current query*/
wp_reset_query();
wp_reset_postdata();
unset($brands_list);?>
<?php else : ?>
<?php /*If there were no paid dealer and no non-paid dealers we must show a 404 error*/
if ($paidnull=="true")
{
echo "<h1 class=\"title\">There Are No Dealers Found for your Search</h1>";
echo "<p style=\"color:#F30\">Use the search below to search a different area</p>";
echo "<br />";
}?>
<?php endif; ?>
</div>