Selecting posts by title
-
I have the following code in a custom page:
<?php $catposts=get_posts'category=3&numberposts=-1&orderby=date&order=desc'); ?> <?php foreach($catposts as $single): ?> ....Do something <?php endforeach; ?>
Problem is that on a large post amount, an “out of memory” error is issued; moreover, I just need some first tenth records to be displayed.
So I have added a filter in functions.php, that filters the recordset by post title:function arabunu () { global $wpdb; $sorgu= "AND $wpdb->posts.post_status='publish' AND $wpdb->posts.post_type='post' AND $wpdb->posts.post_title LIKE 'BLABLABLA%'"; return $sorgu; }
inserting the add filter before the query:
<?php add_filter('posts_where', 'arabunu');?> <?php $catposts=get_posts ('category=3&numberposts=100&orderby=date&order=desc'); ?>
Unfortunatelly the filter is not applied. Any help?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Selecting posts by title’ is closed to new replies.