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

Hide a div from a particular page and single pages in WordPress

Just change this: <?php if( is_page() ) { ?> to: <?php if( is_page() && !is_page(42) ) { ?> You can also try to use is_home() and is_front_page(). These 2 will be even better, since they are more universal (not based on pageId). If you change the page that is your home/front page, this will still … Read more