0

好的,所以我一直在尝试从不同的 div 类中获取特定内容以放入表格中。我正在自定义我的 wordpress 网站。这是我遇到问题的代码

//loops through posts
while ( have_posts() ) : the_post();
       $doc = new DomDocument;
       $doc ->validateOnParse = true;
        $link =  " ' " .  get_permalink()  . " ' "; 
          //this is where the trouble lies.  get error 
          /*Warning: file_get_contents( ' http://www.uwarc.org/?p=60 ' ) [function.file-get-contents]: failed to open stream: No such file or directory in /home/uwarco5/public_html/wp-content/themes/thesis_185/custom/custom_post_loop.php on line 98

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Empty string supplied as input in /home/uwarco5/public_html/wp-content/themes/thesis_185/custom/custom_post_loop.php on line 98 */

    $doc->loadHtml(file_get_contents( $link ));
    echo "<tr onclick=" . $quote . "DoNav(". $quote1 . "get_post_class('site', null)  " . $quote1.  ");" . $quote . ">" ;
    echo "<td align =" . $quote . "center" . $quote . " >" ;
    echo "<div id =". $quote . "org_logo" . $quote . "> <img src =". $quote ; 
    var_dump($doc->getElementByClass('img')) ;
    echo $quote . "width = ".$quote. '150' . $quote. "; </div> " ;
    the_title();
    echo "</td>";
    echo "<td>" . var_dump($doc->getElementByClass('courses')) . "</td>";
    echo "<td>";
    var_dump($doc->getElementByClass('description')); 
    echo "</td>";
    echo "</tr>
      endwhile;?>
4

1 回答 1

0

加载帖子内容:

$doc->loadHTML( apply_filters( 'the_content', get_the_content() ) );
于 2013-05-31T22:16:37.490 回答