• Hi all,

    I have a problem which I am unsure how to resolve….

    I am doing a project for a client at the moment where I will be creating a custom post page which will hold a load of services that the customer offers, for each service I will be adding a load of new meta boxes in my custom post (code side) so it will be nice and easy for my client to add in the relevant content.

    However there is a part needed where they want a table on the page, this table will need new rows adding but we do not know how many, so I need them to be able to click a “New Row” button and then add in the relevant content…. Each row will have a date set (a from date and a to date, not automatically set) – The next issue is I only want them to be able to delete or modify any of the rows which are in the date range, so for example if they created a row with a date range of nov-2011 – nov-2013 this date would have passed so they should not be able to delete this entry… archiving the past entries if you like.

    is this at all possible? can you point me in the right direction? I don’t really want to use a plugin I would rather code it if possible.

    many thanks in advance, if you need any more details please let me know.

Viewing 9 replies - 1 through 9 (of 9 total)
  • hi john. will the customer use the dashboard and the tinymce editor?
    you could extend the tinymce.
    Here is one Example

    Thread Starter johnsimpson_uk

    (@johnsimpson_uk)

    Hi afr0, thanks for your response,

    I wanted to get away from using the tinymce / WYSIWYG as the customer will likely mess the table up and cause problems, also there would be no way to prevent the display of the out of date items without deleting them manually and I need to have them kind of archived on the admin page… I thought about just using the wordpress revisions as the archive but the customer doesn’t want that. They want to be able to see previous entries.

    Thread Starter johnsimpson_uk

    (@johnsimpson_uk)

    can anyone else help?

    Thread Starter johnsimpson_uk

    (@johnsimpson_uk)

    having spent hours today looking into this, it seems i should be able to do what I’m looking for, exactly how I’m not sure but it looks like I need to use the add_post_meta function with an array to include multiple values….

    however i don’t know how to add in a button to a custom post which will trigger the add_post_meta to add in another row?

    can anyone help?

    Hello johnsimpson_uk,

    excuse my english, I#m no native speaker.
    As long as I understood your question, you try to add a button in the edit post page, and this button should be able, to display a new row with input-tags.
    I think you have to use javaScript to create the additional input-filds with an array and count up the index.
    The firs input would be:
    <input name="name[1][]" type="text" size="8" value="value" />
    the second
    <input name="name[2][]" type="text" size="8" value="value" />
    You can create the number in js and save them with update_post_meta.

    Greets paka

    What you’re looking for needs to be done in two separaete locations in two separate ways.

    Firstly, you’ll need to set up a new meta box using add_meta_box() that wil ldisplay any current items and will output the JavaScript that’s needed for step 2.

    Secondly you’ll need to use a JavaScript function to listen on an ‘Add’ button and use that event to add in a new row with whatever fields/details you need to have in it.

    Thirdly, you’ll need to use save_post() to save the values that are passed back from the fields in the meta box. You’ll have to watch your field names as you don’t want any two to be the same or they’ll only take the last value that’s passed. You can get around this using something like name="field[]" to send back arrays, so there’s ways to get around this.

    As for not allowing the user ot edit past dates, add in some code in the meta box that will switch between displaying the data in fields if it’s not passed the date, or displays it as non-editable text if it has passed the date.

    It’s not quite so easy, but it’s not as bad as it sounds. I have odne a lot owrse then this, but it’s not what I’d consider a “beginner” exercise. ??

    Thread Starter johnsimpson_uk

    (@johnsimpson_uk)

    guys this is great thanks I don’t class myself as a beginner but I’m no expert either so I will have a shot at it but if I am really struggling would you be interested in doing this (paid of course).

    I hope you can get it. There’s a lot of resources that will help, and if you get stuck with anything you can post here again and I’m sure you’ll get some help.

    As for getting someone to do it for you, you’re best off posting on https://jobs.wordpress.net/ as asking for paid help on these forums is not exactly encouraged

    Thread Starter johnsimpson_uk

    (@johnsimpson_uk)

    oops sorry ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom Posts with additional features’ is closed to new replies.