Displaying all images from a WordPress post

前端 未结 5 1543
一整个雨季
一整个雨季 2020-12-09 23:36

I have this piece of code I found on some blog, that\'s supposed to display all images from a WordPress post.

function getImage() {
    global $more;
    $m         


        
5条回答
  •  长情又很酷
    2020-12-10 00:19

    Fixed, you need to add an $imgLength.

    function getImage() {
        global $more;
        $more = 1;
        $link = get_permalink();
        $content = get_the_content();
        $count = substr_count($content, '');
            $imgEnd = $imgBeg + $imgLength;
            $postOutput = substr($post, 0, $imgLength+1);
            $postOutput = preg_replace('/width="([0-9]*)" height="([0-9]*)"/', '',$postOutput);;
            if(stristr($postOutput,'

提交回复
热议问题