found how to get form content from post

This commit is contained in:
lenovo
2022-11-02 19:43:04 +01:00
parent 8ed8fc2044
commit e2c8fc08ac

View File

@@ -1,11 +1,65 @@
<?php
function mp_get_published_posts() {
// $get_posts_args = array(
// 'numberposts' => -1,
// 'post_status' => 'publish',
// 'post_type' => 'post',
// );
// $posts_published = get_posts($get_posts_args);
// mp_console_log("posts published: ");
// mp_console_log($posts_published);
// mp_console_log("\n");
// $get_posts_args = array(
// 'numberposts' => -1,
// 'post_status' => 'publish',
// 'post_type' => 'acf-field',
// );
// $posts_published = get_posts($get_posts_args);
// mp_console_log("acf published: ");
// mp_console_log($posts_published);
// mp_console_log("\n");
// $get_posts_args = array(
// 'numberposts' => 1,
// 'post_status' => 'draft',
// 'post_type' => 'post',
// );
// $posts_published = get_posts($get_posts_args);
// mp_console_log("post draft: ");
// mp_console_log($posts_published);
// mp_console_log("\n");
// $get_posts_args = array(
// 'numberposts' => 1,
// 'post_status' => 'draft',
// 'post_type' => 'acf-field',
// );
// $posts_published = get_posts($get_posts_args);
// mp_console_log("acf draft: ");
// mp_console_log($posts_published);
// mp_console_log("\n");
$get_posts_args = array(
'numberposts' => -1,
'post_status' => 'publish',
'post_type' => 'post',
);
return get_posts($get_posts_args);
$posts_published = get_posts($get_posts_args);
mp_console_log("posts: ");
mp_console_log($posts_published);
mp_console_log("\n");
// $post = $posts_published[0];
// mp_console_log("post :");
// mp_console_log($post);
// mp_console_log("\n");
// $adresse = get_field('adresse', $post->ID);
// mp_console_log("field adresse :");
// mp_console_log($adresse);
// mp_console_log("\n");
return $posts_published;
}
function mp_extract_address(&$content) {
@@ -29,10 +83,72 @@ function mp_convert_coordinates(&$address) {
return $coordinates;
}
function mp_post_content($post) {
//temp
$content = $post->post_content;
// $args = array(
// 'page_id' => 29718
// );
// $post_query = new WP_Query( $args );
// mp_console_log("0 tmp_content:");
// if ( $post_query->have_posts() ) {
// mp_console_log("1 tmp_content:");
// while ( $post_query->have_posts() ) {
// $post_query->the_post();
// $tmp_content = apply_filters( 'the_content', get_the_content() );
// mp_console_log("2 tmp_content:");
// mp_console_log($tmp_content);
// }
// }
// wp_reset_query();
// $the_content = $post->post_content;
// $the_content = get_the_content(null, false, $post->ID);
// $the_content = apply_filters( 'the_content', $post->post_content );
// $the_content = apply_filters( 'the_content', $post->post_content, 99 );
// $the_content = apply_filters( 'the_content', $post->post_content, -1 );
// $the_content = apply_filters( 'the_content', get_the_content(null, false, $post->ID) );
// $the_content = apply_filters( 'the_content', get_the_content(null, false, $post->ID), 99 );
// $the_content = apply_filters( 'the_content', get_the_content(null, false, $post->ID), -1 );
// $post_id = $post->ID;
// $post_type = $post->post_type;
// mp_console_log("post_type:");
// mp_console_log($post_type);
// mp_console_log("\n");
// // "post"
// $taxonomies = get_object_taxonomies($post_type);
// mp_console_log("taxonomies:");
// mp_console_log($taxonomies);
// mp_console_log("\n");
// // ["category", "post_tag", "post_format"]
// foreach ($taxonomies as $taxonomy_key => $taxonomy) {
// $terms = get_the_terms($post_id, $taxonomy_key);
// mp_console_log("terms (key = ".$taxonomy_key.") : ");
// mp_console_log($terms);
// mp_console_log("\n");
// $terms = get_the_terms($post_id, $taxonomy);
// mp_console_log("terms (value = ".$taxonomy.") : ");
// mp_console_log($terms);
// mp_console_log("\n");
// }
// mp_console_log("the_content:");
// mp_console_log($the_content);
// mp_console_log("\n");
return $content;
}
function mp_retrieve_address(&$posts_list) {
$locs = array();
foreach ($posts_list as $post_value) {
$content = $post_value->post_content;
foreach ($posts_list as $post) {
$content = mp_post_content($post);
$address = mp_extract_address($content);
if (strlen($address) > 0)
{