[wp-hackers] exporting posts by keyword

Dion Hulse (dd32) wordpress at dd32.id.au
Sat Apr 23 12:50:44 UTC 2011


$wpdb->prepare() is a wrapper around sprintf();
If you wish to use %'s inside the SQL, you'll need to escape them.

You're probably looking for this:
  $where .= $wpdb->prepare("AND post_title LIKE '%s%%' ", $keyword);

On 23 April 2011 22:27, fris <fris at fris.net> wrote:

> Im using the advanced exporter wordpress plugin, im trying to mod the
> plugin, to let me search by keyword (titles) and it will create an export
> file with only those posts.
>
> lines altered
>
> #37
>
> $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : 'all';
>
> #69
>
> ra_export_wp( $author, $category, $post_type, $status, $start_date,
> $end_date, $terms , $keyword);
>
> #115-#117
>
> if ( $keyword and $keyword != 'all' ) {
>                $where .= $wpdb->prepare("AND post_title LIKE '%s%' ",
> $keyword);
>        }
>
> #366-#371 (html)
>
> pastebin link with full code -->
>
> http://pastebin.com/feGPC7cQ
>
> not sure whats going on with this.
>
> Any input would be greatful.
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list