As mentioned in the comments, you are trying to get the ID in the taxonomy archive (template-taxonomy.php
) which is not a post object and has no record in the database. It just tries to show some posts and you may get the first post ID when you use get_te_ID()
function in that archive page.
Using some themes or plugins, you are able to create a page and use that as an archive page. In that case, the get_the_ID()
function is able to return the actual page ID (Out of the loop) because it is a real post object and it has a place in the database.
Related Posts:
- Can I get the ID of an inserted / linked image?
- How do I remove a pre-existing customizer setting?
- wp_redirect() – headers already sent
- Enqueue Stylesheets After Theme’s “rtl.css”
- Why I can’t add a CSS style in this WordPress theme?
- Use __($str) and _e($str) to translate strings with HTML
- Posts in multiple Categories different single.php
- Single Page WordPress Theme – Using page templates
- Confused about image sizing business in WordPress
- Custom Theme: The active theme is broken. Reverting to the default theme
- Creating the modern ‘single page’ html5 css3 layout in wordpress
- How can I stop WP media uploader from creating duplicates of my uploaded images?
- Customize comment list markup
- Have WP Theme update from Git Repository
- How to override BuddyPress 3.0 bp-nouveau theme files?
- Responsive Images – Generating multiple images from Theme Customizer control upload?
- How can a Theme Contain no Header File or Footer File?
- WordPress theme (or plugin) that uses Contenteditable property
- Can a child theme based on Starker theme be released as free to use theme for public use?
- Same footer on all multisites blogs
- Adding “latest from the blog” to the homepage
- Default comments file and how to copy it
- Changing order title and featured image in blog post (Astra theme)
- Unhook action from child theme
- Does any theme support child theme?
- 2 differen’t menus and it’s using same items in both
- How do I save a wordpress theme’s files and install them on another site?
- Custom WordPress install – activate custom theme
- Media Uploader in custom path
- How to remove the header from all pages except home?
- Using AJAX in wordpress theme
- moving an admin submenu item to a top-level position
- Highlight “Show all” item in wp_list_categories
- Attach media to multiple posts
- show a post from a specific post format
- Theme Development: Starter Content after hook
- Is there any WordPress theme for Self Storagae just like Spacer [closed]
- Customizer: save setting/control content to post/page
- Custom page template with custom fields
- Underscore Based Theme File Permissions in Git
- How do I include pre-installed images in a theme?
- Wp_customize_image_control Use Add Media
- Trackbacks not displaying
- Widget Option is Missing
- Post Content Displaying Below ALL Shortcodes Content
- How do I use a color from theme options?
- If you were to start using a WordPress framework today, which one would you use? [closed]
- Register sidebar ‘before’ and ‘after’ html as div rather than li tags
- WordPress Template Part in iFrame
- Is it possible to have a theme that uses only one single page?
- How to include a file only on dashboard widgets page?
- JQuery undefined and Stylesheet loads in bottom along with js files
- Why tags are displayed bellow the content and not inside
- What’s the best way to create a new design for other pages?
- Consequences if using PHP include TEMPLATEPATH?
- Adding a gallery to my first theme
- WP_Query $gallerypage->the_post() giving Undefined offset: 0
- Headless WordPress + Vue.js on the same server
- How do I conditionally defer scripts based on the page name?
- How to place POST TITLE any location inside the posts page
- not getting API setting saved confirmation message after update on option page
- Do I need to re-import Susy to work with it in a child theme? [closed]
- Valid SQL query not returning results
- WP_Query not getting all posts, just tagged posts
- how to hide home nav link in wordpress
- Change Image Sizes for Mobile Theme
- Recommended sidebar / content widths
- Converting a theme to a child theme in a network
- language support in a custom urdu theme
- Understrap-child conditional js script
- In wordpress customizer div still showing even if I hid it with javascript
- Programatically Created Menu not Editable in Dashboard
- Why excerpt hook not working inside ajax function?
- How to make updatable custom WordPress theme?
- How can I access variables from theme in child theme? [closed]
- How to handle theme activation errors?
- change background image on scroll
- Duplicate child theme incl. design changes
- Why .widget-area is outside of .site-content in Underscores starter theme?
- Using wp_add_inline_style Inside a Template File
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Display current taxonomy slug in a post
- How to create multiple customizer controls in one control
- Setting a fluid content width
- Modify comments_popup_link output
- How can I display and excerpt of all pages with a meta_key and meta_value on index.php?
- get_the_excerpt() removes all p tags in page!
- Can you create a custom page with content in the center already defined?
- Change default options on attachment page
- Enable WP to accept standard jQuery code embeding between the tags [duplicate]
- Retina ready for uploaded images which are cropped
- Pagination issue with Single.php
- Allow users to edit home page from WordPress (home.php problems)
- php file child theme directory not overriding parent theme php file [duplicate]
- How do I change the tagline input to textarea?
- Display Page featured Image as well as Posts featured Image
- Creating completely new WordPress site from old WP contents
- can’t add EVENT LISTENER to a element
- Should I create a child theme for a parent custom theme? [closed]
- My theme is full of error messages in the “Customize” screen, but nowhere else