Accessing Correct Database to Create REST API Endpoint

You can access another database using the wpdb class and its associated methods. You will need to instantiate a new connection to the other database using the appropriate credentials. Here is the basic code to set up the new connection and query the database: $mydb = new wpdb(‘username’,’password’,’database’,’localhost’); $rows = $mydb->get_results(“<your SQL query here>”); Replace … Read more

How can I make a function work only for desktops and not for mobiles?

WordPress does have a helper function for detecting mobile devices, wp_is_mobile() (untested): if ( ! wp_is_mobile() ) { echo do_shortcode( ‘[meta_gallery_slider arrows=”false” show_caption=”false” show_title=”false” autoplay=”false” slider_height=”450″]’ ); } As Jacob Peattie mentioned, this is unreliable. Better option is to use CSS to show the output only for viewport widths above specified value (untested): PHP: printf( … Read more

Request initiator chain contains old CDN

It’s possible the script is coming from the database. If you have access to WP CLI, you can use the db search command to search for occurrences in the database, and then the search-replace command to update the occurrences. You’ll likely also want to consider searching for https://https://, as that appears to be occurring in … Read more

WordPress custom block: Link saved in database not retrieved when editing post

Your selectors are wrong. { attributes: { link1: { type: ‘string’, source: ‘attribute’, attribute: ‘href’, selector: ‘.btn-afil-text-card a:first-child’ }, link2: { type: ‘string’, source: ‘attribute’, attribute: ‘href’, selector: ‘.btn-afil-text-card a:last-child’ } }, } Both of your a elements are the first (and last) children of their parents, which means that your attributes are each getting … Read more