function imageHolder($id){
$category = get_the_category($id);
$class=""category-" . strtolower($category[0]->cat_name) . '"';
print <<<HTML
<div class=$class>
This is a Test
</div>
HTML;
}
imageHolder('1');
Please be careful about using ‘/n’ or ‘/r’ symbol in the Heredoc syntax(they might cause the function does not work properly).
Related Posts:
- How can i show post_class() within output loop?
- 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
- The correct method to pass query vars in AJAX using ajaxurl
- Display user’s total comment count outside The Loop
- Getting the action’s tag name within the action
- Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress
- How to add query vars with paginated URLs?
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- wordpress separate registration for different roles
- How to get user by display_name with WP_User_Query
- Changing Link Attributes for Wp_Link_Pages
- Unusable menus and “Illegal widget setting ID: nav_menu_item[]” error
- How to change
- Get only the grandchildren, not the direct children of page/current page?
- Passing POST data from one WP post to another
- Use wp_remote_get to get JSON instagram feed from public profile
- How to add SVG icon above product tab title
- WP_Query sort using multiple numeric meta values
- Call to undefined function issue
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- How can I generate random numbers inside my shortcodes on each implementation?
- custom widget on the footer
- WordPress automatically adding html tag around PHP code
- WordPress does not load page.php, return 404.php
- Converting HTML Template to WordPress Theme
- How to hide all child pages with post_query?
- Saving an array of dynamic repeater data as post_meta
- How can I apply_filters from inside a function?
- Image rotation and editing stopped working in WordPress after upgrading Ubuntu from 16.04 to 18.04
- WordPress asks you for your FTP details if you want to run Automatic Updates/Upgrade Plugins
- Populate editor with some content of a page with a page template
- I want to load in a new class but only if the current page is single-movies.php
- wp query foreach deleting record returning only first or last item
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Skt full width basic slideshow problem
- RTL Stylesheet Confusion with WordPress
- How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]
- get_template_part() not firing within a switch statement when template has new WP_Query
- How to show/hide php table rows based on the content of custom fields
- How to determine from a different folder (outside wordpress) if a visitor is logged into WordPress
- Is a series of update_option calls safe, performance wise?
- how to get serialized post meta
- Scheduling an event inside plugin class is not working
- How to catch wordpress post ID when it’s published
- WP check_ajax_referer() is not working
- How to access or parse key/values that have “string”
- Will I have problem with PHP 5.5 and WordPress 4.9.4?
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- How do i wrap woocomerce attribute in list?
- Removing files programmatically
- How to insert data from metabox to custom table
- How to Generate a list of Most Commented post?
- Updating From Mobile App – Exposing Site to Hacking
- call adminbar greeting in other place
- is user member of a group, show them categories [closed]
- How to add ASCII symbol after each recent post [closed]
- WP_LINK_PAGES Generating Unnecessary Tag
- Why is home page content not displaying with this rewrite rule?
- Add class to ul and li in wp_na
- How can i programmatically change the SKU of a product based on product variation?
- Export post data with xml to other site using php soap
- Execute PHP code only with specific user role
- Repeat a function with 24hrs gap for n number of days
- How to serve WordPress folder over subdomain?
- PHP function for horizontal Woocommerce thumbnails and badges
- How to call my PHP function with AJAX ? wp_query
- How to route root path / to /xyz in nginx?
- Get the same SKU from woocommerce itself for simple and variable products
- Show sidebar only to author of post
- No more get_option(‘date_time’) in WordPress 5.5?
- The style.php file inside theme-engine folder has other content on FTP
- how to add custom select field to wordpress edit page
- How to update post content of all posts with tag?
- Make WooCommerce product categories only show images on homepage
- How to Change Site Elements based on referring URL
- WP post meta – for loop inside for loop
- Insert data from form to database
- My search results are only showing 5 posts?
- WP_query meta_query slow with OR and DATES
- WordPress Query Crashes Browser
- Matching multi user
- customizer live preview layout picker
- WordPress using get_term to retreive slug not working as expected
- auto metakey value on post tile
- On a custom template, should I use wp_footer? [duplicate]
- Front end post submissions do not get submitted in the category
- How to pass parameter that ends up being part of a class name with wordpress shortcode
- how to check for wordpress Query errors
- calling a function from a class in your template
- WordPress and magic quotes
- Dynamically pull the correct email address from a match
- Custom single.php files for different post formats
- Troubleshooting “loopback requests that take too long”
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- Order woo products, but first products must be with acf fields
- Woocommerce – add tracking code to another email template
- How to add custom user role into wordpress
- change title of page dynamically