• Resolved bvk69varghese

    (@bvk69varghese)


    I have integrated the YOP Poll plugin and added the short code in my WordPress post. When I display the post content using ajax all other contents displaying properly in the post. But the short code is displaying as it is eg. [yop_poll id=”1″] in page. How can I resolve this issue. Please help.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author YOP

    (@yourownprogrammer)

    Hello

    I’ve tested the link you posted but it asks for username and password.
    Can you look into this and let us know when we can try again?

    Thread Starter bvk69varghese

    (@bvk69varghese)

    Sorry, I am unable to share the login details of the subscribed user. In my subscriber account we have specials blog posts. We are showing those blogs titles as buttons and click on that it will pass the id of the post to an ajax call and list the blog details to div using jquery ajax. If I post the poll short code inside the post content its displaying as it is in the ajax response.   Below is my ajax response code
    $(function(){
    
    	  $(".text-area .sbblogs").click(function(e){
    		e.preventDefault(); //To prevent the default anchor tag behaviour
    
    		$(".text-area .sbblogs").removeClass('selected');
    		$(this).addClass('selected');
    		var url = this.href;
    			var post_id = $(this).attr("post-id");
    			    var ajaxURL = woocommerce_params.ajax_url;
    			    var ele = this;
    			    $.ajax({
    			    type: 'POST',
    			    url: ajaxURL,
    			    data: {"action": "load-post-content", post_id: post_id },
    				scriptAttrs: { nonce: "Xiojd98a8jd3s9kFiDi29Uijwdu" },
    			    success: function(response) {
    				  //console.log(response);
    				   $(".projectpreviewContent").html(response);
    			    return false;
    			}
    	    		});
    	    });
    	});
    Plugin Author YOP

    (@yourownprogrammer)

    I think I understand what you’re trying to accomplish.

    Can you also share the php code that gets the post content from the db and sends it back?

    Thread Starter bvk69varghese

    (@bvk69varghese)

    This is the code I am using to list the blog content in my them's functions.php
    
    function my_load_ajax_post_content()
    {
      $post = get_post($_POST['post_id']);
    
    	get_template_part( 'contentblog', 'page', array('post' => $post));
    	exit;
    }
    
    add_action( 'wp_ajax_load-post-content', 'my_load_ajax_post_content' );
    
    add_action( 'wp_ajax_nopriv_load-post-content', 'my_load_ajax_post_content' );
    
    Also in my poll option I am using an "Other" option with a text box. Is it safe to use? Are you sanitizing the data before inserting it into DB? Please confirm.
    Plugin Author YOP

    (@yourownprogrammer)

    After calling get_post I think you need to call do_shortcode.

    something like this

    $post = get_post($_POST['post_id']);
    $content = do_shortcode( $post['post_content'] );

    can you give it a try?

    Plugin Author YOP

    (@yourownprogrammer)

    @bvk69varghese were you able to get it to work?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Ajax Post Response Poll Short code is not working’ is closed to new replies.