Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Understanding Blog Linking
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 27, 2017 - 12:42 am

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...

Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
May 28, 2017 - 10:18 am

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/

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 28, 2017 - 11:16 pm

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...

Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
May 29, 2017 - 1:54 am

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/

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 29, 2017 - 2:23 am

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...

Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
May 29, 2017 - 11:07 am

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/

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 29, 2017 - 11:12 am

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...

Avatar
Chris_Andrews
Member
sp_UserOfflineSmall Offline
May 29, 2017 - 11:28 am

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/

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
May 29, 2017 - 12:17 pm

Good news.
We will be here...

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626