Support Forum
well, there does seem to be an inconsistency in the code above...
in this code:
$sql = "UPDATE ".SFPOSTS." SET post_date = ".$post->post_date." WHERE post_id = ".$sfVars['linkedpost'];
spdb_query($sql);
the $sfVars array should be $spVars...
seems it should work... where exactly did you put the code I gave you? try the code change first of course...
Visit Cruise Talk Central and Mr Papa's World
Still seems like the $post->post_date isn't available to the script. I can do this:
$sql = "UPDATE ".SFPOSTS." SET post_date = '2017-02-20 10:06:45' WHERE post_id = ".$spVars['linkedpost'];
and get that date in, but just get the current date if I do $post->post_date
***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/
have to admit, I have sort of lost the bubble here... need to reread - thinking we got sidetracked somewhere...
so what happens if you use $post->post_date??
its a standard wp post object, so should contain the date...
where exactly did you put this code? can you paste it here?
do you know how to debug a bit? where you are trying to do that, can you see what is in $post? maybe add ashow($post); die(); right there and see what is shown...
Visit Cruise Talk Central and Mr Papa's World
In sp-linking-blog.php I've added what's in blue:
add_action('sph_new_post', 'my_linking_code'); add_action('sph_new_post', 'my_linking_code'); function my_linking_code($newpost) { global $spVars; $spVars['linkedpost'] = $newpost['postid'];
$p->saveData();
if (!$p->abort) { $editmode = '0'; if ((isset($_POST['sfedit']) && $_POST['sfedit'] == true) || $links->syncedit == '1') $editmode = '1';
# and then update links table with forum AND topic sp_blog_links_control('save', $post->ID, $forumid, $p->newpost['topicid'], $editmode);
# sync blog and forum tags sp_sync_blog_tags($post->ID, $forumid, $topicid);
# Add the blog post id into the topic record $sql = "UPDATE ".SFTOPICS." SET blog_post_id = ".$post->ID." WHERE topic_id = ".$p->newpost['topicid']; spdb_query($sql);
$sql = "UPDATE ".SFPOSTS." SET post_date = ".$post->post_date." WHERE post_id = ".$spVars['linkedpost'];spdb_query($sql);
} else {
I know, it seems like .$post->post_date. should be in the scope. I just get today's date (at the time I update it) instead of the original published date though.
If I add show($post); die(); after that sql statement and then do an 'update' in the wp page editor, it just crashes the page. I don't get a string.
***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/
did you enter 'show' or 'ashow'??? might seem odd, but it needs to be 'ashow' which is not what you typed...
sorry, havent had a chance yet to actually test this myself... anniversary weekend... and memorial day holiday... but will...
Visit Cruise Talk Central and Mr Papa's World
Oh, ok, I looked up "ashow" related to php and wp and only got hits on "show", so I thought that was what you meant.
Ok, I get this (below), which shows that the post_date is there.... then why am I not getting it into the database? If I can hardcode a date in and it works, I should be able to use $post->post_date ... hmmm, something isn't making sense, relooking at and retesting everything.
stdClass Object ( [ID] => 45449 [post_author] => 1028 [post_date] => 2016-03-10 22:01:01 [post_date_gmt] => 2016-03-11 03:01:01 [post_content] => //article removed for brevity [post_title] => //title removed [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => closed [post_password] => [post_name] => //removed [to_ping] => [pinged] => [post_modified] => 2017-05-29 10:59:03 [post_modified_gmt] => 2017-05-29 14:59:03 [post_content_filtered] => [post_parent] => 0 [guid] => //removed [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 )
***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/
sorry, I just didnt look hard enough and missed the obvious... php syntax error there (which is why I asked about error log)... please try this:
$sql = "UPDATE ".SFPOSTS." SET post_date = '".$post->post_date."' WHERE post_id = ".$spVars['linkedpost']; spdb_query($sql);
be sure to use raw copy on the code... just need single quotes around the date...
Visit Cruise Talk Central and Mr Papa's World
Success 🙂
What kills me is I would have caught that a decade ago, but since I'm using wp on all my sites now and not really doing any coding, I've forgotten stuff and don't have an eye for it anymore. Don't use it and I lose it.
Thanks for helping and sticking with me through this. Next I'll try to figure out the actual hard part, see if I can figure out a way to transfer comments over. That may be beyond what I can do, but I'll look into it at least,
I have been able to hack in in-post adsense ads and some adsense sharing code (the author of the original post gets a 70% adshare on their content) and that's looking good and working well. I'll show it all off when I get done messing with it 🙂
Chris
***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/
1 Guest(s)