The get_the_ID()
function will return the id of the current post in the loop.
If your block is used on a single post page or in a post loop (archive page) you can use this.
Related Posts:
- Display random categories on the front page (Finding and Editing Theme Functions)
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Getting the teaser text without overriding global variables
- “options.php” not found
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Add custom css to theme
- Issues with title-tag and document_title_parts
- How to load scripts/styles specific for a page
- Using classes instead of global functions in functions.php
- Child theme – Overriding ‘require_once’ in functions.php
- Is it ok to use a function to output the text domain name in a wordpress theme
- Issue with get_theme_mod returning a blank value instead of the saved value
- TinyMCE custom styles remove class when switching styles
- Hourly Routine Not Firing ( wp_schedule_event() )
- Add colors to existing color palette without replacing it
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- Overriding core functions in child theme
- Set image size on media and text block with a function
- Change parent theme file function in child themes functions.php
- Theme Demo in live Site
- Dequeue Scripts and Style for Mobile not working?
- Customising widget titles/headings in WP 5.8
- Design view breaking on Pages
- Returning Variables back into a template
- Displaying Widgets
- Theme-Config tab in admin Pannel?
- Best Practice for Syncing Local Development With Staging Development [closed]
- Overwrite Parent Theme add_image_size in Child Theme
- Show excerpt for only first post in query
- How to add css class to image attached in all the posts?
- Is It wrong to use oop approach on functions.php?
- Is there a way to add a class to non current menu item?
- PHP files included in functions.php don’t seem to work
- When using wp_enqueue_script(); in a theme why don’t we use add_action?
- How to use Internationalized human_time_diff() function in Chinese?
- is_dynamic_sidebar always returns true while using Jetpack visibility
- Set WordPress Default Template
- create-guten-block in wordpress theme?
- How can I change the do_action function in footer (copyright area)
- Echo tags used to describe the theme
- Add caption functionality to custom WordPress theme
- Override a theme function in a child theme?
- changing behaviour of get_search_form
- Pulling Twitter RSS feed not working as expected (fatal error)
- How to load jQuery in the footer – nothing works for me
- Use register_setting() in a loop
- How to stop twenty fifteen theme from cropping featured images?
- Add dynamic links in WordPress custom theme
- WordPress website Rs changed to currency symbol
- WordPress menu link doesn’t work properly
- Search filter by Post title OR Meta Title Value [duplicate]
- admin-ajax.php + load-scripts.php hanging for minutes
- Functions in custom theme
- Unique sequential reservation code
- Functions.php Problem
- How to customize the_archive_title()? Cannot figure out how to change the value it produces [duplicate]
- Custom editor color palette colors are not appearing in the editor
- Block editors annoying warnings
- Control the srcset much more (not all sizes in it each time)
- Way to store featured image width and height in two separate variables?
- Excerpt for pages not showing
- Turn get_posts as string into an array for use in theme admin options
- Add php code to wp_print_scripts?
- Functions php shortcode for displaying main menu with no child items
- PHP 7.1 | Warning: A non-numeric value encountered in
- Can’t switch to a child theme using filters template, option_template and option_stylesheet
- I can’t add CSS with functions.php
- WP Customizer API loaded into functions.php
- call_user_func_array() expects parameter 1 to be a valid callback, function
- why can’t i add front.css to my frontpage.php
- Is this an acceptable practice for WordPress theme development?
- Rewrite Question Mark in Post Template with URL Parameter for clean URLs
- How can I assign separate stylesheets to different pages?
- How to make sure relative URL works when site is not on root domain?
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Astra theme – cannot set short product description under the product title (product name)
- Customizing the wp_video_shortcode output with add_filter
- Override category archive page title (not the head title)
- Class parameter in get_avatar args doesn’t get added to output
- Is_Page doesnt detect my page
- Test CDN link from function.php or wp_enqueue_script/style?
- How to customize archive widget only for cpt?
- Add meta data in head from theme
- what is `get_section()` and how to use it?
- How to disable site title and description when custom header is uploaded on the customizer?
- Getting back a blank WordPress site following functions code edit
- 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
- Query custom post type and showing its content
- Random text changing to weird icons in both admin & front end
- Register a widget area when a theme option has been saved?
- Additional Sidebar
- Why functions metaboxes is causing White Screen in Admin [closed]
- Getting error on function.php
- Adding function to function.php error 505 [closed]
- Problem with lists and “allowed_block_types” in functions.php (since WP 6.1.1)
- How to automatically load Google Fonts on pages only as they’re used?