Forums

[resolved] [Plugin: Front-end Editor] Help with custom fields and custom taxonomies (12 posts)

  1. claud925
    Member
    Posted 2 years ago #

    So I used a lot of custom fields and taxonomies for my website. Im not sure how to make them editable...

    Soo this is my code on my function.php for my taxonomies...

    function my_taxonomies() {
    	register_taxonomy( 'genero', 'post', array( 'hierarchical' => false, 'label' => 'Generos', 'query_var' => true, 'rewrite' => false ) );}

    And in my single.php i've got this for my custom fields...

    <?php $numepis = get_post_custom_values('titulo_alternativo');
    if (empty ($numepis)){echo "";} else {
    echo "<strong>T&iacute;tulo(s) Alternativo(s):</strong>";
    foreach ( $numepis as $key => $value ) { echo " $value <br />"; } } ?>

    And this for my custom taxonomies...

    <?php echo get_the_term_list( $post->ID, 'genero', "<strong>G&eacute;nero:</strong> " , ', ', '' ); ?>

    So... where i should put the editable thing?

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

  2. scribu
    Member
    Posted 2 years ago #

    For taxonomies, read this:

    http://scribu.net/wordpress/front-end-editor/fee-1-1.html

    For custom fields, there isn't currently a way to edit a field with multiple values.

  3. claud925
    Member
    Posted 2 years ago #

    MMM... I did what the instructions said, but nothing changed...

  4. scribu
    Member
    Posted 2 years ago #

    Oh, I forgot to mention that you have to replace

    echo get_the_term_list(...

    with

    the_terms(...

  5. claud925
    Member
    Posted 2 years ago #

    Did it and its working perfectly :) Absolutly love this plugin!

  6. claud925
    Member
    Posted 2 years ago #

    could I make my custom fields editable using this guide? http://scribu.net/wordpress/front-end-editor/developer-guide.html
    Asking before messing up my code :)

  7. scribu
    Member
    Posted 2 years ago #

    Download the Development Version (1.6a1) and try this code:

    $numepis = get_editable_post_meta(get_the_ID(), 'titulo_alternativo');
    foreach ( $numepis as $value )
        echo " $value <br />";
  8. claud925
    Member
    Posted 2 years ago #

    Yeah it worked using that code. Thought it only showed the value of the custom field, and not what was before it .
    So added a line before it to show the custom field like it was showned befored:

    <?php $numepis = get_post_custom_values('titulo_alternativo');
    if (empty ($numepis)){echo "";} else {
    echo "<strong>T&iacute;tulo(s) Alternativo(s):</strong>"; } ?>
    <?php $numepis = get_editable_post_meta(get_the_ID(), 'titulo_alternativo');
    foreach ( $numepis as $value )
        echo " $value <br />" ?>

    So it shows something like Título(s) Alternativo(s): "somenamehere"
    and not just "somenamehere".
    I tried to put it just in one php but could not make it works, cause it would shown all the text, even when there wasnt any value inserted in the post.

    I was wondering if there could be some way to make the custom fields more like the taxonomies. I mean, when there isnt a value in a taxonomy there is a text shown like "Genero: [empty]" so you can double click the empty file and edit it. Right now I can only edit the custom fields that are alredy in a post.

  9. scribu
    Member
    Posted 2 years ago #

    I could make it handle all custom fields in a single textarea. Each value would be on a separate line.

    That would allow you to freely add and remove values.

    Still thinking about this.

  10. claud925
    Member
    Posted 2 years ago #

    Well yeah that would do the job just fine.

    Probably you are still thinking about this?

  11. scribu
    Member
    Posted 2 years ago #

    The problem is that custom field values can include newlines in them.

    So I couldn't use newline as a separator between multiple values in all cases.

  12. scribu
    Member
    Posted 2 years ago #

    Also, there might be other issues with hiding a group of elements at once. I don't think I'll include something like this in the plugin.

    For a small donation, I can code a custom class for your particular use-case.

    Send me an email to scribu@gmail.com if you're interested.

Topic Closed

This topic has been closed to new replies.

About this Topic