archive.php doesn’t have a featured image, so this clause will short circuit your logic immediately:
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return;
}
Try moving the has_post_thumbnail
check and your $url
assignment inside the clauses where they make more sense – the clauses that check for post
and page
.
Related Posts:
- Attach parent category template to all subcategories
- Specify multiple categories for custom post template – FATAL ERROR
- Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
- Simplest Way to Build Custom Archives Page?
- Display ACF category image on archive and single template files
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- Get rid of WordPress category, tag and author archives?
- How To Create A Paginated List Of All Categories On My Site?
- How to redirect to post if search results only returns one post
- Order posts (across the whole site) by metadata date
- Get list of years when posts have been published
- How to customize search result page title?
- How to fix a theme with page.php Default Template that accidentally deleted?
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Php string not working in WordPress Functions.php (trying to fetch 1st category for each blog that post appears in the sidebar)
- Add class to Categories Widget
- How to Acheive the custom woocommerce category template
- How to add a rel attribute to images that contains their categories?
- Using locate-template & shortcodes doesn’t appear to work
- Assign category using custom field?
- Can I use require() function in a template file?
- How to set global variables in template page?
- Why isn’t is_page_template() adding a body class?
- How To Get WordPress Categories Link List?
- Query children and parent title
- Which php file lists all the post of a category
- Use template for posts with a particular category grandparent
- Changing post category from dropdown
- Make “sidebar template” the default template for new pages
- Retrieve post modified date for specific post by post ID
- Add class or ID to any WordPress function
- How to remove howdy dropdown menu content
- exclude a category from a search on a specific page
- How to include local menu based on page id?
- Get the category name outside of the loop in category.php
- How to extract the variables out from “add_shortcode” function?
- Default Gallery Edit/Template Editable?
- Possible to display shortcode based on the category?
- Unset Category if other Category is unset during post transition
- WordPress subcategories return 404 in custom template
- Retrieve tags data in post body
- Select pages by category
- How to set default archive image without overriding first attached image? [closed]
- Show Primary Category first when I display post categories
- Restoring default article pagination on archives – Removing custom limits
- Only one post is showing on category page, why?
- How to override p2 breathe theme plugin in content template file?
- Functions For Calling Specific Elements
- Full page template function
- Get category URL for current post
- allow only one post in specific category
- wordpress use single ajax in place of multiple ajax requests in a smarter way
- Add Element as a Filter to the_content
- How to obtain the recent posts without their content in an efficient way?
- Running script based on Category
- I have problems with loading javascripts
- Need print logo without any ID & class
- Define PHP variable from a seperate API if statement
- Function filter breaking tag archive menus
- Best way to handle lack of titles in microblogging
- attachment page template? only show attachments for current post?
- Access category within rss2_head hook?
- issue with if/elseif in_array inside foreach loop display only one post
- Randomizing wp_tag_cloud() in child theme
- Is it possible to have a template that works on multiple categories where the link address contains the specific category?
- add_filter to specific WooCommerce Category
- How to include any template using Shortcode fuction?
- Problem with calling custom function in a foreach loop
- Using functions.php to include code that’s processed inline
- “All posts” in the category widget
- How to make a new function that includes a template
- Displaying year once in category.php [duplicate]
- Show admin page, only if function is being used
- Archive Template being used instead of Category Template for Custom Post Type
- WordPress Categories: Function using custom SQL to return array of specific category IDs
- Get slug of current category in functions.php
- Display a list of random terms from custom taxonomy with shortcode
- Load templates, pass arguments, and render output from functions.php
- Change category display name function
- Changing the HTML of notices in WooCommerce [closed]
- Custom Function.PHP Code Not Working on One Site
- how to remove a tag in the_category function
- Changing author links on homepage to buddypress profiles – without affecting ability to link to author archive throughout the site
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- WordPress function with attribute pass to template
- Graphic before title – Specific Category
- How do I apply a wordpress function to something with no ID inside an archive page?
- different body classes for each category
- Newest comments first not working
- Retrieve a custom form field modified by a filter
- us states dropdown function and echo in theme template files
- How to pass a variable from a template page to the child theme functions.php
- Function the_content
- Allow the access over wp-login.php
- how to pass args for archive.php query?
- How can i hide content if not friend in Buddypress? [closed]
- Which template file to edit to edit homepage in Mystile [closed]
- Make a PHP file with a function
- Creating mixture of shortcodes to use in the visual/text editor
- Removing all Category pages with one exception