Use the global $page
, which holds the current page number.
// Somewhere near the top
if ( $GLOBALS['page'] === 1 && $image_data = get_post_thumbnail_id() ) {
if ( $image_data = wp_get_attachment_image_src( $image_data, 'full' ) ) {
if ( $image_data[1] >= 500 )
the_post_thumbnail( 'top-post' );
}
}
// Further down. $image_data still exists, no need to grab it again.
if ( $GLOBALS['page'] === 1 && $image_data && $image_data[1] < 500 )
the_post_thumbnail();
You’ll see I also a did a little spring cleaning:
- Removed redundant second
$image_data = ...
- Added check that there is indeed a thumbnail
- Added check that
$image_data
exists
Related Posts:
- featured image as background image on pages
- Displaying Child pages of the current page in post format and their thumbnails (featured image)?
- How do I use featured images on index.php?
- Outputting content from page
- Featured Image not displaying in a page
- How do you add a featured image to a page (not post)?
- Check if is on child-page of a particular page
- Create a page without adding a page in the Database
- Restrict admin access to certain pages for certain users
- Require title for pages
- Add a new page to wordpress programmatically
- Get Permalink for the top level parent of child pages
- How do I modify this page template to show subpage excerpts (not post excerpts)?
- List all pages and children in separate ul
- How do I load custom scripts and styles for a page?
- How to build a post and comment editing form in a page?
- Wrong Sub-Page Order
- WP won’t save changes in post (any)
- can i create 2 blog ‘feeds’ within one blog
- Call the content of a page in AJAX in WordPress
- Password Protected Page Not Displaying Content After Entering Password
- Created pages not showing up in ‘All Pages’ list
- Registering multiple sidebars with data from an array
- How to exclude shortcode from specific page IDs if it’s set to global
- How to dynamically save a selected option from page “Templates” selectbox?
- Is it possible to have a landing page based on the visitors location?
- Play Video on Homepage Only
- Extra title output with this function wp_list_pages
- Remove number in URL
- Dynamically change page that loads
- Page title not showing up
- Where is the key _wp_page_template passed?
- How to add Posts to a Page
- Proper way to implement/access a built-in page in my theme
- remove/hide pages from users backend
- Page not found error when adding text `2 = 2 ^ 1` to the page
- Related Links Page with moderated, user suggested link submissions
- If a page does not exist, include a different page?
- Missing Page, But Still Exists In Preview
- Adding Author and Updated Schema Markup to WordPress Static Pages
- Trying to Edit a Page but it sends me to a Product Edit page
- Get the ‘Content Permission’ roles as defined in a page
- Pages are hashed as of today
- Dynamic Landing Page
- Creating a dashboard menu page similar to the “Pages” page
- Get $post Object from another page
- How to edit a HTML list in WordPress?
- Is it possible to activate page template without manually selecting it in wp-admin?
- All Pages visible on the Frontpage
- Google Page Speed Insights not recognising WP-Cofig settings?
- How do we exclude multiple pages (like opposite of is_page)
- How to make a page unsearchable in blog search?
- Query specific Pages
- Phantom page can’t get rid of/can’t get at to change
- Getting ACF Field in Page – From the Footer
- How can I send an email when someone uses the HTML download Attribute?
- Rewrite to load homepage for a different url
- logout redirect only from admin page
- multiple post into single page
- Later blog post pages give 404 error
- Different css file not working for the page template I created
- redirect index.html inside folder to wordpress page of same name
- Show content if page is a grandchild of top level page
- Does Feedburner send notifications about WordPress pages?
- Ordering Pages and Increasing Navigation
- Static Website No Titles But Still Nav
- Search results to be only posts & children of page ID
- What’s the section of code (or loop) which retrieves the Page title and description?
- Embedding Password Protected (Private) “Blog Posts” BLOCK that shows Images and Excerpts on Password Protected Page (not the home page)
- How to backup just pages from my site, but not posts with other post_type values
- On the list of Pages, clicking to Edit a particular page redirects to the list of trash
- My pages are using my Index.php and not my page.php
- WordPress custom pages in a folder
- How to delete the scrollbar in my pages?
- How to make a page as default page for a theme without a plugin?
- Return true if parent page id matches
- Not allow add New Page for role ‘editor’
- How to detect if some page template has been selected
- Why Google map can not show full size in a page?
- Page view displays not properly after update wordpress
- What’s the best way to manage sections on a page?
- How do you assign custom template for Posts page (under Front page displays setting)
- Category Page Custom Layout [closed]
- Prevent page from displaying
- Adding CSS styles to Admin Area PAGES only (not POSTS or CPT)
- 1st Level Page with No Children
- Loading custom jQuery and HTML in a WordPress page
- Add feed to a custom page
- Directory location of new page
- Grabbing the_content from “about us”
- making a pseudo-static page
- Page specific values in widgets
- Woocommerce – Making product pages child of shop
- Show different number of posts on second page of category
- Use get_posts() with ‘post’ and ‘page’ queries at the same time?
- appearance of new page
- How to read a page’s “Shortcodes” from the Template File?
- How can a user login on a wordpress page?
- For some reason my posts are not showing up on my front page [closed]
- Fresh WordPress installation not able to simply show page content