Empty post problem
-
Some template, contains social shortcode which I getting with ajax return empty string.
The problem is in this part
shortcode.php:27global $post; if(!is_object($post) ) { return; }But from code below we can see that post it not required in some cases
shortcode.php:32
if ($customUrl) { $targetUrl = $customUrl; $postId = 0; } elseif ($url) { $targetUrl = $url; $postId = 0; } elseif (is_front_page()) { $targetUrl = esc_url(home_url()); $postId = 0; } elseif (!is_singular() && $type == 'vertical') { $targetUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"])); $postId = 0; } elseif (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']) { $targetUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"])); $postId = $post->ID; } elseif (get_permalink($post->ID)) { $targetUrl = get_permalink($post->ID); $postId = $post->ID; } else { $targetUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"])); $postId = 0; }But even if I specify post url, empty post object( coz it ajax ) not allow me to use this shortocde.
Can you provide a fix? Like
... } elseif (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] && is_object($post)) { ... } elseif (get_permalink($post->ID) && is_object($post)) { ...
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Empty post problem’ is closed to new replies.