WordPress.org

Ready to get started?Download WordPress

Forums

Front-end Editor
[resolved] Use front end editor with checkboxes (10 posts)

  1. urre
    Member
    Posted 3 years ago #

    I'm using the plugin More Fields and have some fields that are checkboxes. Need to edit theese checkboxes in the front end. Is that possible? Use other field types than input, textarea or rich?

  2. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    How would that work? What would you double-click on?

  3. urre
    Member
    Posted 3 years ago #

    maybe if checked > update database with true/false?

  4. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Yeah, that would work.

    My question is this:

    For a text value, you have a text input or a textarea. On the front end, you just show the value as HTML text.

    For a true/false value, you have a checkbox. But how do you display it?

    I guess a potential solution would be to just display 'yes' for true and 'no' for false.

  5. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Check out the development version (2.0-alpha3).

    To display a custom field that's to be edited using a checkbox write:

    editable_post_meta( get_the_ID(), 'my-meta-key', 'checkbox' );

    replacing, of course, 'my-meta-key' with your meta key.

    If you need to replace yes/no with something else, you can write:

    editable_post_meta( get_the_ID(), 'my-meta-key', array(
        'type' => 'checkbox',
        'values' => array( true => 'yes', false => 'no' )
    ) );
  6. urre
    Member
    Posted 3 years ago #

    Thank you for your answers! I will try this now, but the link didn't work (pointed to http://downloads.wordpress.org/plugin/checkbox.zip) ?

  7. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Oups, I meant http://downloads.wordpress.org/plugin/front-end-editor.zip

    You can always reach it by going to Front-end Editor -> Other Versions -> Development Version.

  8. urre
    Member
    Posted 3 years ago #

    Thanks a lot, that worked!

    Have two more questions!

    1.
    I'm wondering if instead of yes/no, displaying a png-image with different graphics on checked/unchecked. Could that be done, for example using jQuery (like .attr("src","graphic.png"); or something?

    2.
    I need to reset all values of a certain custom field, would like to make it a function and run it on a specific php-page. But I don't know exacly how. This code works, but for some reason it executes even it is on a page that is not used (why?)

    $querystr = "
    SELECT wposts.*
    FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
    WHERE wposts.ID = wpostmeta.post_id
    AND wpostmeta.meta_key = 'price'
    AND wpostmeta.meta_value = '50'
    AND wposts.post_status = 'publish'
    AND wposts.post_type = 'post'
    ORDER BY wposts.post_date DESC";
    
    $pageposts = $wpdb->get_results($querystr, OBJECT);
    
    ?>
     <?php if ($pageposts): ?>
    <?php foreach ($pageposts as $post): ?>
    <?php setup_postdata($post); ?>
    <?php update_post_meta($post->ID, 'price', '0'); ?>
    <?php endforeach; ?>
    <?php else : ?>
    <?php endif; ?>

    btw, will definitely donate some money to you, the plugin is great!

  9. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    1.
    I'm wondering if instead of yes/no, displaying a png-image with different graphics on checked/unchecked. Could that be done, for example using jQuery (like .attr("src","graphic.png"); or something?

    You can just send the img tags instead of the 'yes' / 'no' strings.

  10. urre
    Member
    Posted 3 years ago #

    (The img tags worked, but becomes hard to click at)

    old question on this topic,

    Can i make the checkbox beeing unchecked by default?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic