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
- What’s the difference between home_url() and site_url()
- 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
- Programmatically Set First Image as Featured
- Removing default image size list in Media Box
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- WP 4.4. responsive loads normal image after loading the responsive image
- How to add classes to images based on their categories?
- How to create thumbnails for PDF uploads?
- How to reduce original image quality on upload?
- Is it possible to use a forgot password url filter?
- 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?
- Is it possible to maintain image aspect ratio when scaling images?
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- Set image size on media and text block with a function
- What are the meta fields for an attachment?
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- How to properly set custom logo size?
- Add attribute only to first image of every post via functions.php
- How can I set the SRC URL of the custom logo image?
- Need To Change WordPress Meta Tags… Includes wordpress shortcodes
- How to Add Shortcode to html img code?
- 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
- Image Crop Not Working
- Use existing image sizes for WooCommerce
- Problem in using Customizer
- wp_get_attachment_image_src returns image on main domain, false on subdomain
- Retrieve First Image Function
- Custom Image Size in Insert Media
- Featured Image keeps cropping
- Prevent creating multiple image resizes in twentytwelve template
- 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
- Create Custom URL structure for specific Post category using Post ID instead of post name
- Custom image sizes showing in Classic Editor only when upladed directly to post
- Fetch URL parameter
- Different image using srcset function
- Custom route and extract data from slashes and parameter
- Is it possible to limit number of files a non-admin user can upload via the WordPress media library?
- Auto delete content in specific folder inside media library
- How to change images url in function.php?
- reWrite wp-content url to point on my cdn
- How to update an image attachment’s alt text from a custom field when saving a post?
- How to Override Page Template if URL matches query?
- Class parameter in get_avatar args doesn’t get added to output
- large image size of 1440×1440 not pulling 2x of 2880×2880 image
- Add #primary at the end of navlink permalinks on single posts
- Can You Set A Minimum Image Dimension For Resizing Images?
- blank page with wp_get_attachment
- Set URL Parameter Post Layout As Default
- (Divi): How to make WordPress load images of specific size for Blurb modules on given page with a funciton?
- Images with overlay
- Featured image on archive page based on post type
- Printing medium sized image
- restrict uploaded image size and fixed image display size
- 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?
- Different body image backgrounds on different pages, posts and categories
- Instead of using $post, how do i get the thumbnail image of the $post
- 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
- restrict access to specific urls on a specific period of time
- Using conditionals, maybe from a DB, to register & enqueue files, for varying pages, in functions.php
- Full size image option removing problem
- Function to get thumbnail img source
- How do I change the URL returned by next_posts_link()?
- 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