the_post_thumbnail unless video id is added

I think all you need is this: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> if (get_field(‘channel’) == ‘Youtube’) { echo get_field(‘youtube_video_id’); } elseif (get_field(‘channel’) == ‘Vimeo’) { echo get_field(‘vimeo_video_id’); } elseif ( has_post_thumbnail()) { the_post_thumbnail(); } That should use a Youtube video, then a Vimeo video, then the thumbnail, … Read more

Custom fields randomly stop working

get_the_ID() is a post tag. It is meant to be used inside a Loop. Per a comment above you are using it outside the Loop. No, it’s not inside Loop. The code is simply posted within another div, which holds slides for a slideshow. get_the_ID like most post tags depends on a global variable called … Read more

How can I order metaboxes in my posts in WordPress?

<?php $ck = get_post_custom_keys($post_id); //Array foreach ($ck as $k) { if (substr ($k, 0, 1) == ‘_’) { // skip keys starting with ‘_’ continue; } $cv = get_post_custom_values($k, $post_id ); //Array foreach ($cv as $c) { if (empty ($c)) { // skip empty value continue; } echo ($k . ‘: ‘ . $c . … Read more

Cron job to call php to email last 24 hours posts

In your functions.php you can use this. You will have to activate your theme again for it to take effect. You only want to schedule a cron job on activation, not on activation NOT on every page load, which is what the functions.php does, it loads on every page load. This would be betterused in … Read more

!in_array doesnt recognize category

Try it like this: if ( $query->have_posts() ) { $categories = $category_ids = array(); while ( $query->have_posts() ) { $query->the_post(); foreach ( ( get_the_category() ) as $category ) { if ( ! in_array( $category->term_id, $category_ids ) ) { $category_ids[] = $category->term_id; $categories[] = $category; } } }; } get_the_category() returns an array of objects. I … Read more

How to export database correctly for local to online

What Options are you changing after upload to production server? I think after upload .sql file your website don’t want appear in browser? Check it: After import your local .sql file to production server, log in to production/phpmyadmin website, go to wp_options and check values: | option_id | option_name | option_value | —————————————— | id=1 … Read more