Function in WordPress D8 theme to capture the first image of an article and display it
Release: 2016-07-25 09:13:04
Original
1113 people have browsed it
取自 WordPress D8 主题; 路径 themed8modules ;
- if ( ! function_exists( 'deel_thumbnail' ) ) :
- function deel_thumbnail() {
- global $post;
- if ( has_post_thumbnail() ) {
- $domsxe = simplexml_load_string(get_the_post_thumbnail());
- $thumbnailsrc = $domsxe->attributes()->src;
- echo '';
- } else {
- $content = $post->post_content;
- preg_match_all('/
/sim', $content, $strResult, PREG_PATTERN_ORDER);
- $n = count($strResult[1]);
- if($n > 0){
- echo '';
- }else {
- echo '';
- }
- }
- }
- endif;
复制代码
|
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-09-06 13:00:25
-
2024-09-06 12:31:29
-
2024-09-06 12:30:03
-
2024-09-06 12:26:29
-
2024-09-06 12:12:28
-
2024-09-06 12:11:28
-
2024-09-06 12:10:28
-
2024-09-06 12:09:28
-
2024-09-06 12:08:28
-
2024-09-06 12:07:28