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?
- Display random categories on the front page (Finding and Editing Theme Functions)
- 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 override admin-bar style
- How to add classes to images based on their categories?
- current_cat_ancestor Alternatives
- wp_get_attachment_image returns different image size
- Passing variables to templates (alternatives to globalizing variables)
- Load post with a different template?
- Change number of posts to show on Archive page (custom post type)
- Add body class of category parent
- 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
- WordPress Change Post Templates,but not drop down, but Image selection
- 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?
- How to set child post categories to parent post categories when updating parent post?
- 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?
- Dequeue script in template isn’t working
- How To Get WordPress Categories Link List?
- Query children and parent title
- Help to resolve Syntax error, unexpected ‘endwhile’ (T_ENDWHILE) [closed]
- Which php file lists all the post of a category
- Display only posts from referred category on date archive page
- Adjust which tempalte a page uses with a function?
- How to change menu icon which is overriden (i.e. by WooCommerce) [closed]
- Use template for posts with a particular category grandparent
- Changing post category from dropdown
- Manipulate Output of wp_list_something: select menu instead of li’s
- Make “sidebar template” the default template for new pages
- Make Categories a Dropdown Menu in Media Library
- Retrieve post modified date for specific post by post ID
- Programmatically Create Category and sub Category
- 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 create function from code?
- Is it possible to change any of the HTML/URL returned from the_category()
- Display Password Protected external RSS in wordpress template
- How to extract the variables out from “add_shortcode” function?
- Default Gallery Edit/Template Editable?
- Custom HTML in specific category single page and its descendant categories
- How to enable template page only for a post id page
- Possible to display shortcode based on the category?
- Selective Product Category for Carousel
- How to change login labels
- Unset Category if other Category is unset during post transition
- WordPress subcategories return 404 in custom template
- Modify a function without editing template
- Retrieve tags data in post body
- Select pages by category
- How to set default archive image without overriding first attached image? [closed]
- Archive.php filtered by pre-determined category
- Show Primary Category first when I display post categories
- How do I hide or remove ‘Category’ from wordpress breadcrumbs
- Ordering posts by publish date not working?
- How can I define a custom archive for childs of a specific category?
- 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
- Categories as main menu items and subcategories as nested lists
- Pagination in relation to archive.php
- Get category URL for current post
- Need help “sanitizing” a custom function that pulls category slug into body class
- 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?
- Setting a default text for excerpts of a particular category
- Running script based on Category
- Remove a category from a post when saving a new post
- How to fix get_the_category function returning incorrect slug?
- Return category name with & Ampersand doesnt work
- I have problems with loading javascripts
- Pass variable from action back to template
- 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?