New answers tagged

3

Turns out meta_query was the way to go. This is the code I used to make it work. add_action( 'pre_get_posts', 'filter_posts' ); function filter_posts( $query ) { $now = date("Y-m-d H:i", strtotime('+2 hours')); if( is_category() && !is_admin() && $query->is_main_query() ) { $query->set( 'posts_per_page','10' ); ...


0

Even though this is specific for OceanWP, the solution is plain Wordpress. Add these two lines to the end of your functions.php to render the shortcodes in both the_excerpt() and get_the_excerpt(). add_filter( 'the_excerpt', 'do_shortcode' ); add_filter('get_the_excerpt', 'do_shortcode');


0

I think this might be part of the problem in your past query (the second one) array( 'key' => 'end_date', 'compare' => 'BETWEEN', 'type' => 'NUMERIC', 'value' => array($past, $now), ), You're using BETWEEN but I think something like < would be what you want. You don't ...


1

Based on the screenshot I assumed is var_dump of your $item The code should look like <?php $item = get_post_meta($post->ID, 'occupationalCategory', false); ?> <?php print_r( $item['occupationalCategory'][0] ); ?>; <?php print_r( $item['occupationalCategory'][1] ); ?> $item contains array, with a element which key is '...


0

usually i'm typing a barcode or an sku number. so i'm fetching 1 result. when i'm not using this script the search results are taking about 2-3 seconds. this is my script: function cf_search_join( $join ) { global $wpdb; if ( is_search() ) { $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta ...


1

My question is, is there a similar selector for when you don't know the post type of a post beforehand? No, at the current time of writing there is not. The fundamental problem is that the REST API doesn't provide a generic mechanism for getting a post type given a post ID. You can retrieve a post and it will say post but to do this you need to know the ...


0

Or to add them for all pages, except the homepage: <?php if ( is_front_page() ) { $canonical_url = get_home_url(); } else { $canonical_url = get_permalink(); } ?> <link rel="canonical" href="<?php echo $canonical_url ?>" />


1

When you do this: '_related_posts': [post.id], you're actually overriding the entire array or the meta value, so to instead append an item to the existing array, you can use the spread (...) syntax like so: '_related_posts': [ ...meta._related_posts, post.id ]. But you may want not want to update the meta if the selected post ID is already in the current ...


0

May be this thread could be useful to you: Also you could explain a bit more what's the pourpouse of those images. Are they going to be printed in the fontend or in the admin side? Do you need them to be uploaded from the frontend or they can be retrived from the wordpress media uploads ? If so, you could create a src field in order to get the image source ...


Top 50 recent answers are included