I'm currently working on a health and fitness website where a user inputs their daily calories and macro nutrients information (carbs, fat and protein). I have thousands of food items with custom meta for calories, carbs, fat and protein. I've developed a search that can find food items between set values using a meta query but now I would like to try and take it to the next level. For example, if a user wants to have 200g of carbs, …
I am trying to setup a custom plugin that will compare the time (last activity of a user) and send emails to them. I am using the below WP_User_Query and a cron job function reminder_email() { // Get the contributors and authors who haven't logged in for 60 days - DO I NEED TO SET UP W3C Total Cache IN SOMEWAY IN ORDER FOR THE Query TO WORK? I DONT HAVE DB OR OBJECT CACHE ENABLED $remind_users = new WP_User_Query( …
I’m trying to compare two dates (the current date with an ACF datepicker one) to display specific content. What I’m trying to achieve is to display a phrase if the ACF date is lower than the current time (in few words if a service is expired). This is my code: $dataScadenza = get_field('data_di_scadenza'); $currentDateTime = date('d.m.y'); if($dataScadenza <= $currentDateTime) { echo '<a href="'.get_field('link_esito').'">'; echo '<button class="vedi_esiti">VEDI ESITI</button>'; echo '</a>'; } else { echo '<span class="ds_label">data scadenza</span>'; echo '<div class="ds_date">'.get_field('data_di_scadenza').'</div>'; } …
I'm having some difficulty comparing between a negative and positive number. This code works fine when it's between two positive numbers but not when it's between a negative then a positive one. This is part of my 'meta_query': array_push($metaQuery, array('relation' => 'AND', array( 'key' => 'longitude', 'value' => array($minlng, $maxlng), 'compare' => 'BETWEEN', ), ) ); If for instance the $minlng is -1.5 and the $maxlng is 1.5. It will pass through values that equal -3. Here is a var_dump …
could someone please tell me where the mistake is in my PHP code? My PHP knowledge is extremely rudimentary although I have tried it with http://php.net/manual/de/language.operators.logical.php :-D "translated" it should mean something like: Single Post -> Show reading time: yes Custom Post Type "wpdmpro" -> Show reading time: no The function for the reading time works per se, but not in the way I put it together concerning the combination with the CPT. With my code the reading time is …
I have a custom post type event in WordPress, and I need to query upcoming event posts comparing $current_date. Query conditions are : start_date is a valid date always end_date can be a valid date or null or empty string. IF end_date is a valid date in db record then compare end_date >= $current_date ELSE IF end_date is null or empty then compare start_date >=$current_date. Now If end_date was not optional , I could use below code to get desired …
Im trying to create a conditional statement comparing two dates. I have a ACF custom date field as one date, and then comparing against the current date. Below is what i have and iv echoed both $date and $currentdate and they both come out in the same format, so im not sure why it wont work. They both output in the format like: 20170105 which i beleive they need to be to compare. <?php $currentdate = current_time('Ymd'); $date = get_field('course_start_date', …
I want to compare the date of a user's last two posts. I'm new to WordPress developing. I have written this code but I'm not sure if it's correct. Please help me in correcting it: $ID = $post->ID; $user_id = $post->post_author; $author_recent_posts = get_most_recent_post_of_user( $user_id ); $last_post_id = $author_recent_posts[1]->post_id; $last_post = get_post($last_post_id); $last_post_date = $last_post->post_date; $post_date = $post->post_date; if ( $post_date - $last_post_date > 24*60*60 ) return;
I am trying to display a particular block of html for one page in particular. I have created a conditional statement that compares the basename of the page to my string. <?php if ( has_tag( 'Sponsor' ) && basename( get_permalink() != 'sponsor-one') ) : // show sponsor's footer if applicable ?> <div class="sponsor-footer <?php echo basename( get_permalink() ); ?>"> <p>Our text here</p> </div> <?php elseif ( has_tag( 'Sponsor' ) && basename( get_permalink() == 'sponsor-one') ) : // show sponsor one's …
I'll give up. Have searched and searched and tried and tried... Can't find any solution to list previous posts. On a single post: I want to show a list of the 10 previous posts, the 10 before the current post. So, not just a two prev and next links. Not the most recent posts that is. A list of the the 10 previous posts before the current post you are visiting. I'm trying to make a query and comparing post_date …
I am using this code to get stuff based on my custom field and custom content type. $searchTerm = 'bestafricanvideos'; $args = array( 'post_type' => 'sitemaps', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'cstm_sitemap_url', 'value' => $searchTerm, 'compare' => 'LIKE', ), ) ); print_r($args); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); $video_url = rwmb_meta('cstm_sitemap_url'); print_r($video_url); endwhile; else : echo "No video URL found"; exit; endif; wp_reset_postdata(); print_r($video_url); And …
I have made a code for to filter wich pages to show depending on your user_role. Everything was alright. But my customer created NEW roles with similars name/slug. So now, if some 1 have the role for exemple : Group APTNB, he will be able to see pages with role APTNB_CA because in the slug 'aptnb' is LIKE 'aptnb_ca' in my comparaison. I have try to explore the possibility to use 'IN' with this post : Meta_query compare operator explanation …
I have set up a wordpress in a way that posts can be cloned and be altered by a different author. whenever this is the case, i want the administrator to be notified via an additional tab in the edit.php screen like Changes(5) where only posts are listed whose content and meta fields differ from those of their originals. to achive this i thought of writing some sort of hash whenever a post is saved to then only compare hashes. …
I wanted to create an "comparasion" model for my WordPress Website, but gone bad at that. I cannot figure out how to ... On one page I have displayed post (custom post type, ex. "Products"). Next to the title of the post (product) is an checkbox. If user has checked for example two posts/products (ex. product a and product b), how to retrive the value (the $post->ID) of each checkbox or over ? How to save that checked $post->ID of …
Quick question, in API's some times save_post is used(most of the time actually). Is save_post the equivalent of the query action INSERT INTO whereas save_post saves metadata and forces Wordpress to do the rest of the work when used correctly? Thanks in advance!
While developing a multipupose theme for mass audience, i’m facing an issue. I’m going to code staff listing section. Now i was wondering, what should i do? 1: Create dedicated Custom Post Type for staff; or 2: Create Shortcode for it. Now each decision has some pros and cons. a) Custom Post Type: Centralization, can call same group of listing on mutiple places without defining each time. Better staff order managerment No need to enter detail page link specifically Taxonomy …