Tag Info

New answers tagged

1

User Meta Query with RLIKE: If the birth date is stored like dd/mm/yyyy, in the user meta, then you could find all August birthday users with the following meta query: 'meta_query' => [ [ 'key' => 'birthday', 'value' => '/08/', 'compare' => 'RLIKE' ], ] You could also consider storing the birthday month ...


0

Create a php script ( fpw-swap-thumbnails.php ) with the code below and put it in root of your site: <?php // load WordPress environment require( 'wp-load.php' ); $args = array( 'posts_per_page' => -1, 'post_type' => array( 'post', 'page' ), 'post_status' => 'publish' ); // get all published posts of type specified in $args $posts ...


1

prepare accepts three placeholder arguments-- " %s (string), %d (integer) and %f (float)". You have used %i. That isn't going to get through the sanitization process. That is why you are getting 0. You need %d instead.


1

qwip, There is one way to update your custom table while wordpress users table in action and for that you require to code with custom function which is called while some action perform by user. You can handle it by add_action(). There are several action act by wordpress for user(viz. user_register, deleted_user, etc). See below code example for that: ...


2

So what I'm going to do going forward if I use wordpress for this project is to create a reverse post id index. I don't think this is the "correct" answer and some people will definitely outright disagree with this approach but this is working for me in production. I got the idea from reading this blog post here: ...


4

pre_get_posts allows you to alter the query arguments very early on in a request. You can modify anything that would be a valid WP_Query argument, including the LIMIT via the posts_per_page argument. This allows much, much broader range of effects than posts_limits which only allows you to alter one part of the database query SQL. In your case, use ...


4

Note that here you're overriding the paging of the main query, with the posts_limits filter, by using hardcoded values: 'LIMIT 0, 25' where 0 is the offset and 25 is the number of posts to display. So in this case I would just use pre_get_posts with $query->set( 'posts_per_page', 25 ); and we don't have to worry about the paging. If i wanted to ...


0

Hi The tables that you need to consider is wp_posts - Which contains all the details about the posts. wp_postmeta - Which is used to store the meta details for a post with relation to post_id. Query will be Select * FROM wp_posts a, wp_postmeta b WHERE a.post_status = 'published' AND a.post_id = b.post_id AND b.meta_key = 'Your Custom Field'; wp_terms, ...



Top 50 recent answers are included