1

im trying using module python-wordpress-xmlrpc to edit my post title. But error at last line. Dont know 'EditPost' usage. Can someone explain with example?

#find allpost 'movie'
  allpost = client.call(posts.GetPosts({'post_type':'movie'}))

 #find post title 'Bumblebee' n change 'Bumblebee 2018'
  for post in allpost:
      if post.title =='Bumblebee':
         post.title = 'Bumblebee 2018'

         client.call(posts.EditPost(post.id, post))

Error:

Traceback (most recent call last):
 File "D:\Movie Website\remote upload\post.py", line 28, in <module>
   wp.call(EditPost(post.id,post))
 File "C:\Python27\lib\site-packages\wordpress_xmlrpc\base.py", line 37, 
   in call
  raw_result = server_method(*args)
 File "C:\Python27\lib\xmlrpclib.py", line 1243, in __call__
  return self.__send(self.__name, args)
 File "C:\Python27\lib\xmlrpclib.py", line 1602, in __request
  verbose=self.__verbose
 File "C:\Python27\lib\xmlrpclib.py", line 1283, in request
 return self.single_request(host, handler, request_body, verbose)
File "C:\Python27\lib\xmlrpclib.py", line 1316, in single_request
return self.parse_response(response)
 File "C:\Python27\lib\xmlrpclib.py", line 1493, in parse_response
return u.close()
 File "C:\Python27\lib\xmlrpclib.py", line 800, in close
 raise Fault(**self._stack[0])
 xmlrpclib.Fault: <Fault 404: 'Invalid attachment ID.'>
uyin
  • 19
  • 3
  • Can you re format the question so that the code can be properly seen? Also include the error. – saud Dec 20 '18 at 07:30
  • Ok..done edit..hope you can solve my problem – uyin Dec 20 '18 at 08:08
  • " But error at last line" is a mostly useless description of your problem. Please post the eact error message and the full traceback. – bruno desthuilliers Dec 20 '18 at 08:58
  • I forgot to add..add error.. – uyin Dec 20 '18 at 10:04
  • Looking at [this issue](https://github.com/maxcutler/python-wordpress-xmlrpc/issues/29), it seems like the posts which we get by `GetPosts` have more data than posts expected in `EditPost`. I don't have an environment to test this myself. Try and see if it works. – saud Dec 20 '18 at 15:10
  • Anyone can give correct code EditPost usage? – uyin Dec 21 '18 at 02:54

1 Answers1

0

add in loop:

post.thumbnail = post.thumbnail['attachment_id']

or:

post.thumbnail = post.id
Zaraki Kenpachi
  • 5,510
  • 2
  • 15
  • 38