WordPress.org

Forums

Simple Fields
[resolved] Simple fields assign to category (6 posts)

  1. tsurom
    Member
    Posted 1 year ago #

    Hello,
    thank you for this great plugin. Even i don't know anything bout php i managed it to create a custom side.
    Now my problem: i nserterted the code
    $selected_value = simple_fields_get_post_value(get_the_id(), array(1, 4), true);
    echo "Anbieter: $selected_value </br>";
    // outputs: "Anbieter: ";
    into my single.php.
    Works fine, but now it is on every Post, even its not filled out. How can i assign this only to a specific categoryusing the code above?

    Thanks in advance.
    Tsurom

    http://wordpress.org/extend/plugins/simple-fields/

  2. Pär Thernström
    Member
    Plugin Author

    Posted 1 year ago #

    Something like this could perhaps do it:

    $selected_value = simple_fields_get_post_value(get_the_id(), array(1, 4), true);
    if ($selected_value) {
      echo "Anbieter: $selected_value </br>";
    }
  3. tsurom
    Member
    Posted 1 year ago #

    Thats it!!!
    Thank you!
    This tells the empty arguments not to appear? smart, thanks

  4. tsurom
    Member
    Posted 1 year ago #

    Hi Pär, one more question. All the field types works with this simple code, except the file field. This gives out a number instead of a picture. When i insert a picture in the textfield with WYSIWYG Editor it works.
    So what is missing in this code to show pictures:

    $selected_value = simple_fields_get_post_value(get_the_id(), array(1, 4), true);
    if ($selected_value) {
    echo "Anbieter: $selected_value </br>";
    }

    Thanks again
    Tsurom

  5. Pär Thernström
    Member
    Plugin Author

    Posted 1 year ago #

    If you use the file field, the number you get is the id of the image selected. You must then use another function,
    for example
    http://codex.wordpress.org/Function_Reference/wp_get_attachment_url

  6. tsurom
    Member
    Posted 1 year ago #

    Thanks for the answer, but i don't understand it. I want in a field group with textboxes a pictures to chose and display on a post. I can realise it with the WYSIWYG Editor Textfield and the code
    $selected_value = simple_fields_get_post_value(get_the_id(), array(1, 4), true);
    if ($selected_value) {
    echo "Anbieter: $selected_value </br>";
    }

    But it would be more elegant if there is only a picture to chose.
    As i mentioned before i have no idea about php, so i just used your examples and that worked fine for me.
    Is there a way to use the examplecode for a picture?
    Greetings from Japan
    Tsurom

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags