Forums

Front-end Editor
[resolved] Apply Front-end Editor to post loaded with ajax? (6 posts)

  1. bsieders
    Member
    Posted 7 months ago #

    What code do I have to add to make a post loaded via ajax editable with Front End Editor?

    In my ajax.php file I have added the wp-blog-header which should load the plugin but it does not seem to do anything with the standard wp loop that follows.

    define('WP_USE_THEMES', false);
    require('../../../wp-blog-header.php');
    header("HTTP/1.1 200 OK");
    do_action('template_redirect');

    query_posts(array('p'=>$_POST['postid']));
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    ........

    Thanks a lot in advance

    http://wordpress.org/extend/plugins/front-end-editor/

  2. scribu
    Member
    Posted 7 months ago #

    You don't need your own ajax.php file. Just use the one that comes with WP:

    http://codex.wordpress.org/AJAX_in_Plugins

  3. bsieders
    Member
    Posted 7 months ago #

    Thanks for your quick response :)

    I have tried the approach you suggested but the_title remains uneditable with FEE :p

    Here is my new php code:

    add_action("wp_ajax_addpost", "addpost_callback");
    add_action("wp_ajax_nopriv_addpost", "addpost_callback");
    
    function addpost_callback(){
    	query_posts(array('posts_per_page'=>1));
    	if (have_posts()) : while (have_posts()) : the_post();
    		the_title();
    	endwhile;endif;
    }

    And jQuery (i'm testing this on xampp):

    jQuery.ajax({
       	type: "POST",
       	url:"http://localhost/public_html/wp-admin/admin-ajax.php",
       	data: {action: 'addpost'},
       	success: function(msg){
    	    alert(msg);
    	}
    });

    Am I missing something else?

    Cheers!

  4. scribu
    Member
    Posted 7 months ago #

  5. bsieders
    Member
    Posted 7 months ago #

    Thanks,
    I downloaded the latest development version and added
    FEE_Core::add_filters(); to the front of my callback and I see the fee classes are being applied correctly.

    It still doesnt hover the edit button though so I called jQuery('.fee-field').each(FrontEndEditor.make_editable); after the content has loaded but that doesn't seem to do it either.. am I close?!

    Awesome support by the way, two thumbs up :p

  6. scribu
    Member
    Posted 1 month ago #

Reply

You must log in to post.

About this Plugin

About this Topic