You should use get_post_class()
From Codex:
get_post_class()
is not simply a non-echoing alternative to
post_class()
.get_post_class()
does not return a string, but an array
that must be processed to produce text similar to what is echoed by
post_class()
.
So
$classes = get_post_class();
$output="<div id="" . get_the_ID() . '" class="' . implode(" ", $classes) . '"></div>';
Related Posts:
- How to add post classes?
- How to edit the styles for the table of pages/post listed in the admin when you click on pages/posts?
- WordPress call post-ID in jquery
- PHP Use Declared array Variable inside already Declared Array
- Decrease file size upload in Media
- If Custom Field is empty don’t display div
- the_author_posts_link css class
- error_log is not working as expected in functions.php file
- WordPress template_include filter not working properly
- Web scraping using transients
- PHP Script for last login time
- Why the JavaScript code is ignored from wp editor?
- Send an email to specific adress when button is clicked?
- PHP version problem?
- Why Won’t My Inputs in a form with a Get method work together?
- Automatic Shortcode Creation with Custom Fields [closed]
- WordPress function when file is uploaded, deleted or edited
- WordPress function and string as variable?
- Permission callback to check if user has application password
- Hide posts if user is added to it WP_query
- Set default Database Storage Engine when creating tables with plugins?
- How to deal with a GET variable of ‘name’?
- Replace a single variable with add_filter
- I am having issue in divi woocomerce checkout module. (DIVI theme)
- Trying to use a variable to set image width
- What is the correct way to search 3 custom fields only in WordPress?
- How to change order inside foreach using wp_enqueue_script?
- Adding extra data to shortcode attributes and pass it to JS with wp_localize_script
- Related Posts: if there is no category use tags
- Subheader title depends on post – change to static
- Make the text field in search form optional
- Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
- Adding a Sub Menu Options Page WP Backend Menu. Whats wrong with my code?
- how to add display_name
- Too few arguments to function woocommerce_update_product_acf_save_post()
- WordPress Query -> Ajax Query
- Can WordPress support Website (19GB database) Should I move Our WordPress Website to a custom one using Laravel or any other PHP framework?
- WordPress Importer Call to undefined function set_time_limit()
- Display terms on product page with shotrcode
- How to build a dropdown with tags for same post type?
- WCFM Custom form
- Stop breadcrumb function retrieving custom post type template name
- Slug not being updated using wp_insert_post
- How do I run the following script from my articles page?
- Redirect users by role to custom pages
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- The search doesn’t work properly
- Having trouble customizing toolbar on wp_editor
- Load wp_editor on button click
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- Should I use include(_once) or require(_once) for loading php-file with customizer settings?
- How to create a WordPress PAGE in another folder?
- How do I edit the text in this function.php file?
- How to make WordPress search.php display all strings found on pages or posts
- get second ID from array
- Add topbar to static html page
- Execute multiple PHP Snippets causes error?
- Social Sharing Buttons in Recent Articles List
- use wpdb object on other file
- Field validation strlen works in php7.4 fails 8.1 [closed]
- How do I get a function to work in single.php
- Save Edit button then disabled readonly metabox
- Embed PHP script into WP – what is the best way
- Using global variables
- WordPress different custom tag being displayed in on tag list
- getJSON response to PHP
- Custom plugin with shortcode not working
- Get category name of current post (CPT UI)
- Filtering image class at output
- Three different queries on same page
- Removing the add to cart button from specific product pages
- I want to show image from custom field image on my custom page template
- Replace block content with an array
- How to create custom user role without plugin?
- WordPress 6.1.1 shows deprecated errors with PHP 8.1 & 8.2
- Include a static block inside of a dynamic block
- How can one use variables in a template or template part without polluting the global scope?
- wp_login_url always redirects me to wp-admin
- Add Woocommerce Customers link to custom admin menu
- Preventing script injections in HTML form
- How to add a php package to an existing wordpress website
- wp_register_script – illegal string offset
- Warning: Undefined property: wpdb::$question_overview in C:\Wamp.NET\sites\proxyvragenmodule\wordpress\wp-includes\class-wpdb.php
- How can I remove paginated SEO titles from my WordPress site?
- What is wrong with my sorting logic?
- Count the number of matching post names in foreach loop
- what to do after instlling cyberpanel on VPS
- Weird Javascript:void(0) code in my website
- PayPal button not showing and cannot retrieve order error in PayPal
- Why do I get a 404 error on my custom post type archive pagination?
- Need Help With Making Full-Width Template for Blog Posts (common methods aren’t working)
- change div text and link for logged in users
- Font Awesome Icons as squares [closed]
- index.php changed on its own
- Exclude a category ID from the following function
- How can I modify the html output of a custom post type admin page?
- How do I change the color of a pop-up on the main page?
- Add text below WooCommerce short description if metabox value is true
- ACF number less than comparison not working
- Deprecated: Return type of WC_Appointments_Availability::offsetExists($offset) [closed]