Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获取joomla post图像_Php_Wordpress_Joomla_Joomla2.5 - Fatal编程技术网

Php 获取joomla post图像

Php 获取joomla post图像,php,wordpress,joomla,joomla2.5,Php,Wordpress,Joomla,Joomla2.5,我写不好英语。我使用joomla 2.5,我想转换成wprd出版社 我为这个动作编写了一个插件,我能够传输内容和类别 但我无法将内容的图像从joomla传输到wp!这是我的代码: <?php require_once 'wp-blog-header.php'; require_once 'wp-admin/includes/taxonomy.php'; header('Content-Type: text/html; charset=UTF-8'); global $wpdb; $wp_c

我写不好英语。我使用joomla 2.5,我想转换成wprd出版社

我为这个动作编写了一个插件,我能够传输内容和类别

但我无法将内容的图像从joomla传输到wp!这是我的代码:

<?php
require_once 'wp-blog-header.php';
require_once 'wp-admin/includes/taxonomy.php';
header('Content-Type: text/html; charset=UTF-8');
global $wpdb;
$wp_cat_id = array('11' => '74', '12' => '174', ....);

$con = mysql_connect("localhost", "....", "...") or die(mysql_error());

$db = mysql_select_db('tebroomc_tebnew');
mysql_query("set character_set_results='utf8'");
$result = mysql_query("SELECT * FROM `bme5k_categories` WHERE `parent_id` = 1 AND `level` = 1 AND `published` != -2 AND `metadesc` != ''") or die(mysql_error());

while ($root_cat = mysql_fetch_object($result)) {
    $result2 = mysql_query("SELECT * FROM `bme5k_categories` WHERE `parent_id` =" . $root_cat->id . " AND `level` = 2 AND `published` != -2") or die(mysql_error());

    $my_cat = $root_cat->id;
//    $wp_root_cat_id = wp_insert_category($my_cat);

    $root_cat_posts_sql = mysql_query("SELECT * FROM `bme5k_content` WHERE `catid` = " . $root_cat->id . " ") or die(mysql_error());
    if (mysql_num_rows($root_cat_posts_sql) > 0) {
        while ($posts = mysql_fetch_object($root_cat_posts_sql)) {

            $my_post = array(
                'post_title' => $posts->title,
                'post_content' => $posts->introtext,
                'post_status' => 'publish',
                'post_author' => 1,
                'post_category' => array($wp_cat_id[$my_cat]),
                'post_date'      =>$posts->publish_up
            );
            wp_insert_post($my_post);
        }
    }

    while ($sub_cat = mysql_fetch_object($result2)) {
        $my_cat = $sub_cat->id;

        $sub_cat_posts_sql = mysql_query("SELECT * FROM `bme5k_content` WHERE `catid` = " . $sub_cat->id . " ") or die(mysql_error());
        if (mysql_num_rows($sub_cat_posts_sql) > 0) {
            while ($posts = mysql_fetch_object($sub_cat_posts_sql)) {
                $my_post = array(
                    'post_title' => $posts->title,
                    'post_content' => $posts->introtext,
                    'post_status' => 'publish',
                    'post_author' => 1,
                    'post_category' => array($wp_cat_id[$my_cat]),
                    'post_date'      =>$posts->publish_up
                );
                wp_insert_post($my_post);
            }
        }
    }
}
我把这段代码放在word press的根站点上。现在我想知道,当我从joomla那里读到一个内容,并且我已经将内容转移到word press中时,我怎样才能得到那篇文章的图像呢?

这真的要看情况而定。 通常Joomla不会将图像映射到数据库中,它们只是插入到标记中。 如果您将/images文件夹复制到wordpress,它们可能会立即工作

然而,在_content表的images字段中可能设置了一些图像,尽管这是J2.5上几乎从未使用过的功能,因此不太可能。无论如何,如果使用它们,您仍然可以在/images文件夹中找到它们

Joomla 2.5中字段的典型内容为:

{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
要读取它,只需使用

$images = json_decode($posts->images)
然后你可以用

$images->image_intro 

等等。

我不知道你为什么说它几乎从未被使用过,事实上,从我的问题中可以看出,很多人喜欢用图像进行标准化布局。也许这是意大利本地的东西,在我见过的所有2.5个网站中,没有一个使用了内容->图像;我第一次看到的是J3。