Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Busca o primeiro link do post para o formato LINK. Se não houver link, traz o título do post
- // Colar no arquivo functions.php
- function temabase_get_the_post_format_url() {
- global $post, $posts;
- $first_link = '';
- ob_start();
- ob_end_clean();
- $output = preg_match_all('/<a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>([^<]+|.*?)?<\/a>/is', $post->post_content, $matches);
- if (empty($matches[0]))
- return the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>');
- $first_link = $matches [0] [0];
- return '<h2 class="entry-title link">' . $first_link . '</h2>';
- }
- // Susbstitue o título do post - colar no arquivo content-link.php
- if (is_single()): the_title('<h1 class="entry-title">', '</h1>');
- else: echo temabase_get_the_post_format_url();
- endif;
Advertisement
Add Comment
Please, Sign In to add comment