the_permalink()
and the_post_thumbnail()
echo their output. Use the "get_*
version of those functions, get_the_permalink()
and get_the_post_thumbnail()
when concatenating a string to be output.
Both the_post_thumbnail()
and get_the_post_thumbnail()
will echo/return <img>
tags so don’t wrap their output in an <img>
tag because it’s already taken care of by those functions.
The original HTML posted is missing quotes and I’m not sure why you have the <head>
, <style>
, and <body>
tags in there; those tags are not necessary.
This code will output a linked image:
<?php
echo '<a href="' . get_the_permalink() . '" target="_blank">' .
get_the_post_thumbnail( get_the_ID(), 'video' ) . '</a>';
?>
Related Posts:
- WP_Query create html structure
- Display posts side by side with custom query
- Is there a way to control both Order By and Order query parameters from one input field
- Can wp_query return posts meta in a single request?
- Broken? WP_Query and “attachment” as a post type
- How to use the_posts_navigation for wp_query and get_posts?
- Secondary Sort (fallback) for WP_Query
- How to paginate attachments in a secondary query as gallery?
- How to stop wordpress to make the default query?
- How to make an activities stream mixing posts and comments?
- Single page theme that uses pages for the content
- Order posts ascending with number in title
- using wp_query to return posts w/ comment count > 0
- Order by meta_key in custom post type doesn’t affect the query
- Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?
- wp_transients | wp_object_cache VS SESSIONS & Cookies?
- How to hide post content/meta from everyone except the post author and admin
- Add a default meta_value to new posts
- WP query exclude post within the last month / only show over 1 month old
- Too many posts cause slow load when paginating
- When querying a combination of posts and other meta fields, is there a better solution than directly modifying the WHERE value?
- Order Posts by meta value AND published date
- Formulate a url to show posts with both taxonomy terms
- How to reduce the number of queries?
- WordPress Related Post by tags in Single.php
- List of the years with posts presented
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Query custom post type by custom taxonomy (category slug)
- Advanced Taxonomy Queries WordPress
- Getting post revision and printing them on the post content site
- Editing the default wordpress search
- Use posts_groupby filter with part of string in wp_query?
- wp_query for multiple cities (multiple values in a metabox)
- get posts by meta_key from inside key of post meta
- Help optimizing slow WP_Query with meta_query
- Pre-Populate $wp_query settings with custom rewrite rules and custom template_redirect
- WordPress Blog Posts with Pagination inside a Page/Post
- exclude a post from wp_query loop
- Is_single() conditional tag returns null in query
- Limit home post to 10 without creating pagination?
- Is it possible to query a custom field where the value is between two fields?
- WP_Query args to show posts from specific custom taxonomy
- How to query woocommerce product by pricing? [closed]
- WP_Query Meta_key is text value and need to sort as numeric not working
- filter wp_query result with custom field values
- Posts in loop all show the same author when there are many authors
- If have posts a week old, display, else display a different loop
- Create a page template for “top rated posts” but show full content and not just a list
- Why tax_query in WP_Query not working
- All blog data on a page using custom query gives 404 for page 2 and onward
- construct complex queries with WP User Query
- How do I fit WP_Query arguments into a function?
- Querying a large number of posts including their custom fields data
- Group posts by attachment meta key
- date_query is showing duplicate results
- How to query posts for custom post type with featured image for first 2 post?
- Why is get_the_excerpt returning full content
- Randomly pick one testimonial post
- WP_Query with 2 genres
- Display posts from an array of ID’s
- Date not appearing in custom query
- Custom post type – filter content by custom meta box content
- Trying to output content from page, works locally but not online
- How can I modify the query by adding to the existing query?
- WP_Query Regexp whitespace and end of string
- Custom order of posts in wp_query and different taxonomies
- Update wp_query every week
- Count post meta entries
- use mysql variable in a $wpdb->query to reindex a column?
- wp_insert_post with ACF Fields and WP Meta Query returns no rows until update
- Search with WP_Query, but ignore href URLs in anchor tags?
- Displaying Pages in Nav Sub-Menu with Specific Taxonomy Terms?
- Multiple meta_query not working
- Is meta_key used for ordering, filtering, or both?
- compare for multiple meta values for same key in wp_query
- Save query in function for custom gallery
- Merge two queries and remove duplicate
- Convert SQL Query to WP_Query
- Taxonomy Terms That Don’t Exist Display Results
- Why is my query not giving results?
- Get a page ancestor from a most viewed list
- What argument does my function need to echo get_results() query results
- Custom pagination (Title, date and teaser)
- Using custom field as ‘orderby’ value causing post grouping by publish date
- Sorting Posts with meta value not working
- Display posts from catagories
- Add pagination to table generated by wp_query
- Adding a Theme Customizer Control for Posts_Per_Page
- Fire query on ajax post url page
- using next-page and previous page inside a wp_query
- Custom query from all posts & all child page from one parent page?
- What is wrong with this pagination code?
- wp_query conditionally get posts
- how to add limit records in wordpress query
- query only direct child and sub-terms of a current term archive
- restrict posts per page
- the_excerpt() not working in custom archive
- WP_Query by meta key not returning any posts
- How to retrieve _embed (etc) fields in get_posts custom query?
- Using ‘meta_query’ with the ‘pre_get_posts()’ hook disables searching for post titles