I would try something like this:
function bg_image_topic_titlearea() {
if ( ! function_exists( 'bbp_get_topic_id' ) ) {
return false;
}
if ( ! $letztezifferimgs = bbp_get_topic_id() ) {
return false;
}
$letztezifferimgs = substr( $letztezifferimgs, - 1 );
// switch ...
return true;
}
I would recommend checking to make sure the function call (bbp_get_topic_id();
) to retrieve the Topic ID exists.
I would recommend checking to see if there’s actually a value received from the function call to retrieve the Topic ID.
Not sure why you need to use substr();
, but perform that once you know you have received a Topic ID.
THEN perform your switch
.
I would also recommend placing a “default case” in your switch statement.
Example of a “default case”:
default:
// do something...
break;
Related Posts:
- Need to convert image url to a Base_64 data url with wordpress function..
- Conditional function for excluding first image from content, not working
- how can I change all wordpress media file url to custom cdn url?
- Missing feature image link function
- Why isn’t is_page working when I put it in the functions.php file?
- Add image size if page template
- Set JPEG compression for specific custom image sizes
- Prevent “main” WPMU site_url() being returned in functions
- Custom page with variables in url. Nice url with add_rewrite_rule
- remove links from images using functions.php
- Issue with wp_get_attachment_image() and SVG file type
- How to change the markup WordPress inserts for post images
- Removing default image size list in Media Box
- WP 4.4. responsive loads normal image after loading the responsive image
- How to create thumbnails for PDF uploads?
- Create Custom URL structure for specific Post category
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- Why are image thumbnails cropped proportionally (not per dimensions)?
- Gallery images titles – get from post
- Remove images from get_the_excerpt
- How can I rename the WordPress AJAX URL? [duplicate]
- How to add a rel attribute to images that contains their categories?
- Why are image thumbnails cropped proportionally (not per dimensions)?
- Best way to programatically add “rel” attributes to page and post images
- Conditions for Users and Visitors
- Overwrite Parent Theme add_image_size in Child Theme
- Images uploaded using media uploader are appearing upside down
- Count total number of images in post and echo results as number
- How can you limit srcset on a single type of page?
- Automatically wrap multiple images in div
- Understanding and altering the structure of posted images
- Overwriting Parent Theme’s Image Sizes
- Image rotation fails to regenerate custom sized thumbnail
- How to Display Frontend CSS for Administrator only
- Featured Image Thumbnail Creation
- Twentyten Child Theme: header images display messed up in admin panel
- Display images that are not in the content
- Removing custom meta data
- show first 3 thumbnails of posts in different sizes [closed]
- Getting custom image size URL in functions
- Set spesific size of featured images
- meta tags doesnt fetch data from permalinks
- Scrape external webpage for first image and add it to new post
- media resize/crop possibilities?
- Get arguments from URL
- Control the srcset much more (not all sizes in it each time)
- Way to store featured image width and height in two separate variables?
- srcset and custom field get_post_meta and wp_get_attachment_url
- Limit dimensions of “Full” size images
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- Add unique id to Preview URL
- Conditional statement not working in function
- What are the meta fields for an attachment?
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- Add attribute only to first image of every post via functions.php
- Need To Change WordPress Meta Tags… Includes wordpress shortcodes
- How to add a new image size and apply it to posts only?
- Protect get_query_var from manual input in url
- Function to insert missing image size attributes into img tags
- Problem with images URL after filter applying
- Custom Image Size in Insert Media
- How i can get the URL?
- Using add_image_size in functions.php to get original uploaded file
- get_image_tag() html output : empty src attribute
- include w_thumbnail_src in function?
- Need To Resize Images Exactly Without Losing Image Details
- Custom image sizes showing in Classic Editor only when upladed directly to post
- Fetch URL parameter
- How to change images url in function.php?
- reWrite wp-content url to point on my cdn
- How to Override Page Template if URL matches query?
- Class parameter in get_avatar args doesn’t get added to output
- Add #primary at the end of navlink permalinks on single posts
- blank page with wp_get_attachment
- Images with overlay
- Featured image on archive page based on post type
- Printing medium sized image
- Why am I losing image quality on my site?
- Replace image attributes for lazyload plugin on image elements with specific class
- Disable links to images only if link is an image
- Restricted images only for logged user. (hidden url)
- Zip all (original) images from media gallery
- No compression occurs on my jpegs after adding jpeg_quality hook to my functions.php file
- How to display content If function exist/condition true?
- Update add_image_size
- Function the_content
- How to add a meta information to the URL?
- Open image size links in a page instead of direct image link
- Dynamically adding Captions to images
- Full size image option removing problem
- Function to get thumbnail img source
- Function in functions.php by url
- Image width issue in IE [closed]
- image_size with respect to aspect ratios
- How to resize image from import image url?
- How to crop image in WordPress with aspect ratio for any size of image
- How to add height and width dimensions automatically to archive descriptions
- How to overwrite image if it already exists – WordPress, Gravity form