Bootstrap 5 Carousel Caption Outside of Image

By default Bootstrap 5, put the caption on the image and no way you can change the caption position by modifying only the Bootstrap CSS.

You need to change the CSS and add jQuery to do this.

After few tries, I manage to do put the carousel caption outside of images for large screen. For small screen the caption is still on the image.

For small screen, to make the caption outside of image, you can change the CSS by using CSS media screen.

bootstrap 5 carousel caption outside image
bootstrap 5 carousel caption outside image

Demo – Bootstrap 5 Carousel Caption Outside Image

How To Change Bootstrap 5 Carousel Caption Position

CSS Not to Display Default Caption Position

Add CSS to Display New Carousel Caption Position

You can change the CSS to where you want to put your text.

Add jQuery Script to Retrieve Current Caption

Add id to each carousel-caption

Full Source Code

WordPress add wp media

I want to add a media screen to upload photos to a custom post type. I did search the internet but found the solutions were bit an pieces.

What I plan to do – Add Media Screen to Custom Post Type

1) When click on the Add Media – media screen will apppear
2) User can select a photo and when a photo is selected, it will replace the previous photo.

wordpress - add wp media screen to a custom post type
when click on the add media button, a media screen will appear
wordpress - media screen appear on custom post type
media screen appears after clicking on the button.
wordpress - select new photo
wordpress – select new photo
wordpress - new photo replaced the previous one
wordpress – new photo replaced the previous one

How To Do It?

1) Add below javascript

2) Enqueue the script

3) Add this PHP code  to your plugin

Code Explanation

All the codes are self explanatory and with comments. I just want to highlight which code you can change the title of the media screen.

wordpress - wp media change its default title
wordpress – wp media change its default title

 

References:

https://stackoverflow.com/questions/21540951/custom-wp-media-with-arguments-support

Google reCaptcha v2 Doesn’t Work using PHP on my Website

My website is a WordPress website. I wanted to create a form with a reCaptcha protection using Google reCaptcha v2 (tick box). Surprisingly it doesn’t work even though it works on my other website using same PHP code.

After Ticking the reCaptcha

google recaptcha v2 tick box
google recaptcha v2 tick box

It doesn’t work if use file_get_contents

Google reCaptcha keeps sending me error.

It works if using curl

 

 

PHP is not running on MacOS Monterey on Apple Macbook Pro M1

PHP is removed when I upgraded my Macbook Pro M1 from Big Sur to Monterey. Apache web server is still running though.

This solution doesn’t work! I blog it as reference for others that it doesn’t work so they can try another solution.

I’m still figuring it out. 🙂

My phpMyAdmin is showing its PHP Code

phpMyAdmin shown in plaintext in macos monterey
phpMyAdmin shown in plaintext in macos monterey

Install Rosetta2

Install PHP

Link the PHP

Check if PHP is installed

if correctly installed, you will see

Location of php.ini

Edit Apache httpd.conf

Change These Settings inside httpd.conf

 

References:

https://laracasts.com/discuss/channels/servers/php-shown-as-plaintext-mac-monterey

https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions

https://stackoverflow.com/questions/64963370/error-cannot-install-in-homebrew-on-arm-processor-in-intel-default-prefix-usr

WordPress How To Change Page Title Programmatically

If you want to change your page title dynamically which change the title tag <title>, check whether your theme has this code under functions.php

If yes, if you want to change the page title dynamically, you must call below filter.

Check that your theme header.php doesn’t contain any title tag. It only contains wp_head()

 

I spent so much time finding this solution, maybe I didn’t typed the right keywords in search engine.

WordPress media_handle_sideload error message of Specified file failed upload test.

I got error “Specified file failed upload test.” when I try to upload image file using media_handle_sideload(). It took me several hours just to solve this. Haha

My HTML Form

My PHP

 

The error is not really verbose, it should say empty file found rather then failed test. My mistake I forgot to put the index ‘filename’ as in my form.

Solution

 

WordPress wp_title Hook Filter Not Working

When I use wp_title filter hook, the title on the browser doesn’t change. To solve this ensure at your theme header.php, there is wp_title() at the title tag.

Then you can use the wp_title filter.

Bootstrap version 5 Text On Image When Hover or Static Text

I couldn’t find an easy tutorial how to do text on image for Bootstrap version 5 when you mouse hover an image or a static text on the image.
So I have to try few solutions before get it right.

The solution is using purely CSS without any Javascript

The CSS

How To Use It

  1. Wrap the image in a div with class=”text-on-image”
  2. Under the div wrapper,include a text div with class=”text”
  3. You can add link or button

Demo on JSFiddle

Macbook M1 MacOS Big Sur Error MySQL PhpMyAdmin When Login

I login to MySQL using phpMyAdmin with root account and it produced this error.

Login root via terminal

I was able to login using my root password means something configuration is not correct.

macbook M1 mysql login via terminal
macbook M1 mysql login via terminal

When I googled, I found 2 solutions. I tried the first one but fail. So I documented the one that works with Macbook M1 MacOS Big Sur.

Update root Password via Terminal

Login Again At Your phpMyAdmin

It should work by now using root and the updated password.

WordPress How To Get Variable from Rewrite Rules

I was scratching my head on how to get the variable from WordPress rewrite rules. In one of Stackoverflow post, it was mentioned we could use $_GET and in some posts proposed to use get_query_var() but when I tried both were emptied.

The Correct Way To get Get Variable from Rewrite Rules

But some conditions must be fulfilled. Please read on.

If Using get_query_var is still Empty means you use non standard variable name

Here is the list of standard query vars that you can use.

Register Your Variable Name

If you use your custom variable, you must add the variable as below.

Ensure Your Regex Has ^ at the beginning and $ at the end

If not, WordPress standard rewrite rules will be executed first and you can ‘t get your variable value.

The Full Code

Make sure you press save at Settings -> Permalinks.