Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> XMLRPC + WORDPRESS aktualizacja danych postu
tomeknh
post
Post #1





Grupa: Zarejestrowani
Postów: 90
Pomógł: 0
Dołączył: 2.12.2007

Ostrzeżenie: (0%)
-----


Witam,

W kodzie skórki Wordpress mam takie coś odpowiedzialne za dodawanie oferty:

  1. update_post_meta( $property_id, 'REAL_HOMES_property_bedrooms', floatval( $_POST['bedrooms'] ) );


oraz

  1. wp_set_object_terms( $property_id , $property_features, 'property-feature' );



i teraz mam pytanie jak za pomocą XMLRPC zaktualizować te pola?

Kombinuję tak niestety nie działa:

  1. // konfiguracja
  2. $usr = 'admin';
  3. $pwd = 'admin';
  4. $xmlrpc = 'http://localhost/k2invest_wordpress/xmlrpc.php';
  5. $client = new IXR_Client($xmlrpc);
  6. $client->debug = false; // opcja debugowania true lub false
  7.  
  8.  
  9.  
  10.  
  11. // aktualizacja postu
  12.  
  13. $post_content2 = array(
  14. 'post_status' => 'publish', //publish
  15. 'post_meta' => array(
  16.  
  17. 'REAL_HOMES_property_bathrooms' => '1'
  18. )
  19. )
  20.  
  21. );
  22. $media2= $client->query('wp.editPost',0, $usr, $pwd, 348, $post_content2);



Czy ktoś ma pomysły?
Go to the top of the page
+Quote Post
andrew654
post
Post #2





Grupa: Zarejestrowani
Postów: 35
Pomógł: 9
Dołączył: 16.11.2012

Ostrzeżenie: (0%)
-----


W editPost jest chyba custom_fields a nie post_meta, sprawdź to:


  1. $post_content2 = array(
  2. 'post_status' => 'publish',
  3. 'custom_fields' => array(
  4. 'REAL_HOMES_property_bathrooms' => 1
  5. )
  6. )
Go to the top of the page
+Quote Post
tomeknh
post
Post #3





Grupa: Zarejestrowani
Postów: 90
Pomógł: 0
Dołączył: 2.12.2007

Ostrzeżenie: (0%)
-----


Super działa, dziękuję kolejny raz za pomoc.

A orientujesz się co z

  1. wp_set_object_terms( $property_id , $property_features, 'property-feature' );


(IMG:style_emoticons/default/questionmark.gif) (IMG:style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
andrew654
post
Post #4





Grupa: Zarejestrowani
Postów: 35
Pomógł: 9
Dołączył: 16.11.2012

Ostrzeżenie: (0%)
-----


object terms to tagi albo kategorie, zależy jak zapisane. Trzeba w dokumentacje zajrzeć wordpress;)
Go to the top of the page
+Quote Post
tomeknh
post
Post #5





Grupa: Zarejestrowani
Postów: 90
Pomógł: 0
Dołączył: 2.12.2007

Ostrzeżenie: (0%)
-----


mam dość już tego kodu WP na dziś (IMG:style_emoticons/default/wink.gif)
przeczytałem całego google na temat object terms i niestety nic nie działa

masz jakiś pomysł jak to w ogóle uruchomić?

więc to jest na 90% jako kategorie

to jest ostatni element jaki mi brakuję (IMG:style_emoticons/default/smile.gif) proszę o pomoc (IMG:style_emoticons/default/smile.gif)

  1. $taxonomy = array(
  2. array( 'key' => 'property-type', 'value' => 36 ),
  3. );
  4.  
  5. $post_content2 = array(
  6. 'post_status' => 'publish', //publish
  7. 'post_thumbnail' => $image_returnInfo['id'],
  8. 'custom_fields' => $custom_fields2,
  9. 'tags' => $taxonomy
  10. );



kombinuję tak tylko to nie będzie jako 'tags' - ostatnia linijka kodu
Go to the top of the page
+Quote Post
andrew654
post
Post #6





Grupa: Zarejestrowani
Postów: 35
Pomógł: 9
Dołączył: 16.11.2012

Ostrzeżenie: (0%)
-----


W dokumentacji newPost, editPost jest coś takiego:

struct terms: Taxonomy names as keys, array of term IDs as values.
struct terms_names: Taxonomy names as keys, array of term names as values.

Jak chcesz to edytować to podejrzewam że podobnie jak custom_fields.

Tutaj masz dokumentację wp_set_object_terms: https://codex.wordpress.org/Function_Refere...et_object_terms

  1. wp_set_object_terms( $property_id , $property_features, 'property-feature' );


Z tego wychodzi, że:
$property_id - id postu,
$property_features - nazwy lub id tagów/kategorii
'property-feature' - Custom post type, czyli dodany rodzaj postów
Go to the top of the page
+Quote Post
tomeknh
post
Post #7





Grupa: Zarejestrowani
Postów: 90
Pomógł: 0
Dołączył: 2.12.2007

Ostrzeżenie: (0%)
-----


  1. $post_content3 = array(
  2. 'post_type' => 'property-feature', //publish
  3. 'property-type' => 36
  4. );
  5.  
  6. $media3= $client->query('wp.editPost',0, $usr, $pwd, $postID, $post_content3);



próbuję tak ale niestety nie dodaję się (IMG:style_emoticons/default/sad.gif)

  1. $custom_fields3 = array(
  2. array( 'key' => 'property_features', 'value' => 36 ),
  3. array( 'key' => 'property_id', 'value' => $postID), // cena oferty
  4. );
  5.  
  6.  
  7. $post_content2 = array(
  8. 'post_status' => 'publish', //publish
  9. 'post_thumbnail' => $image_returnInfo['id'],
  10. 'custom_fields' => $custom_fields2,
  11. 'property_feature' => $custom_fields3
  12. );
  13.  
  14. $media2= $client->query('wp.editPost',0, $usr, $pwd, $postID, $post_content2);



ani tak też nie działa (IMG:style_emoticons/default/sad.gif)

Dobra to inaczej - ma ktoś może pomysł , mając dostęp dostęp do bazy danych MySQL gdzie znajdują się wordpress jakim zapytaniem wykonać taki kod:

wp_set_object_terms( $property_id, intval( $_POST['type'] ), 'property-type' );
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.09.2025 - 14:03