register_activation_hook isn’t adding table to DB

Note that the $file in register_activation_hook( $file, $callback ), should be equal to path to the main plugin file, but when you have it in a sub file as __FILE__ then it’s not the same! That means your callback is never called. I would also recommend prefixing the function’s name to avoid possible name collision … Read more

Edit post_content on posts with Featured Image

I would do this as follows: Back up the entire DB (or certainly the wp_posts table!) Run this query to get all posts that have a featured image: SELECT wp_posts.* FROM wp_postmeta INNER JOIN wp_posts ON (wp_postmeta.post_id = wp_posts.ID) AND meta_key=’_thumbnail_id’; Export the results to a plain SQL file with SQL inserts Do your search … Read more

List of posts by day of the week

What about using just get_posts (removing the order_by argument), then looping through to create and array of programs, then building the output from that: $posts = get_posts(array(‘post_type’=>’programas’,’meta_key’=>’audio_date’)); $programs = array(); foreach ($posts as $post) { $days = get_post_meta( $post->ID, ‘audio_date’, true ); // $time = get_post_meta( $post->ID, ‘audio_time’, true); $found = false; foreach ($days as … Read more

Cron While Editing Post

It seems to have solved by changing the two functions, by taking a different approach: /* CHECK IF CURRENT USER IS NOT IN POST.PHP AND IN POST-NEW.PHP AND DOWNGRADE PUBLISH POSTS IN PENDING AFTER X DAYS */ if(is_admin() ) {global $pagenow; if( ‘post.php’ != $pagenow || ‘post-new.php’ != $pagenow) { add_action( ‘init’, ‘downgrade_publish_posts’ ); function … Read more

How to update records using $wpdb?

Logic of my function was all wrong, should have sorted the result in $trans_array before the foreach loop. Here is the updated code that worked, if anyone needs it: function rkm_translation_update() { global $wpdb; $trans_row = $wpdb->get_row(“SELECT * FROM id_item_lid”, OBJECT, 0); $id = $trans_row->id; $item = $trans_row->item_id; $lid = $trans_row->lid; $trans_array = $wpdb->get_results(“SELECT * … Read more

SQL query to get adjacent posts from search query

Although this is possible, it really is not viable. I’ve done a lot of research on this subject, but could not find a straight forward answer I went and had a look at the WP_Query class for a possible solution, and I came to the conclusion that what I was trying to accomplish would not … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)