WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Front-end Editor] It breaks when the loop is a custom select query (7 posts)

  1. ricardormz
    Member
    Posted 4 years ago #

    I have a category_dates.php where i want to show and be able to edit right there 5 different posts.

    I did it. Everything was working just fine, everything was editable (wordpress tags and custom fields). But now i realize that i have to do a custom select query because i need to sort the posts based on a custom field date (mm/dd/yy).

    Im using setup_postdata($post); and evrything is showing up just fine. The problem is that if a do this, none of the wordpress tags (such as the_title(); or the_content();) become editable now.

    However, the custom fields, like:
    <?php editable_post_meta(get_the_ID(), 'Fecha','input'); ?>
    are still working just fine, i can edit them without any problem.

    What can i do?

  2. ricardormz
    Member
    Posted 4 years ago #

    What im going to do is a query_posts loop. The only problem i have with this is that my custom field DATE is a string (mm/dd/yy), not an actual date. So if i sort it like this:

    <?php query_posts('meta_key=date&orderby=meta_value&order=ASC'); ?>;

    Will return this:
    Jan 2010
    Feb 2010
    Oct 2009
    Nov 2009
    Dic 2009

    Instead of:
    Oct 2009
    Nov 2009
    Dec 2009
    Jan 2010
    Feb 2010

    I know this have absolutely nothing to do with this plugin. But just to let everyone know that this plugin doesnt work well with custom select query loops.

  3. scribu
    Member
    Posted 4 years ago #

    You're right: it has nothing to do with the plugin, but with your custom fields.

    You should save the date in this format: 2009-10-31 and then write:

    <?php date_l10n(editable_post_meta(get_the_ID(), 'Fecha','input'), 'date format'); ?>

    The only problem is that editable_post_meta echoes the output instead of returning it. You can change that in fields.php.

  4. ricardormz
    Member
    Posted 4 years ago #

    This did the trick:

    <?php query_posts('cat=85&showposts=12&meta_key=Fecha&orderby=date(meta_value, Y m j)&order=ASC'); ?>

    I didnt know that i could use date() inside the query_posts();

    Thanks for your time. Your plugin is gonna help me alot.

    Just to let you know, im using it to build an event planner. I have to come up with events and parties at least twice a week. We are 5 people working on this. So i needed a nice clean (and shared) way to keep everyone up to date.

    So with the help of custom-field-templates plugin I established the variables (date, cost, description of the event, bands playing, and image).

    Now, I will creat a bunch of posts because i already know that i have to plan an event, lets say 8 weeks from now. I will set the date for every single one and i will keep them in a category called future_event (which isnt shown on the public website).

    Once the post is edited and done, then we will change the category to public_event to become a public post. So its a cool way to do everything just once. Everything is there in the post before it goes public.

    Thanks again.

  5. scribu
    Member
    Posted 4 years ago #

    date() happens to also be a function in SQL. :-)

    Interesting use of WordPress. But I don't get where you're going to use FEE.

  6. ricardormz
    Member
    Posted 4 years ago #

    Im using FEE to build a front-end interface easy to use. My coworkers dont know anything about wordpress, but they know how to doble click and type.

  7. scribu
    Member
    Posted 4 years ago #

    Oh, nice. Good luck.

Topic Closed

This topic has been closed to new replies.

About this Topic