document.addEventListener('DOMContentLoaded', function () {
// Get the contact element by its ID
var contactElement = document.getElementById('contact');
// Check if the contact element exists
if (contactElement) {
// Scroll to the contact element with smooth behavior
contactElement.scrollIntoView({
behavior: 'smooth'
});
}
});Smooth Scroll to Contact Element on DOM Content Load
javascript
Related Posts
More content you might like
Code
How to Create a New MySQL User with Full Privileges
No preview available for this content.
May 01, 2025
Read More Code
python
Configuring SQLAlchemy with PostgreSQL on Heroku: A Quick Guide
Without this replacement, SQLAlchemy might throw an error like:
ValueError: Could not parse rfc1738 URL from string 'postgres://...'Nov 08, 2024
Read More Code
php
How to Delete All WordPress Posts and Their Uploads Using a Custom PHP Script
You can loop through all posts, delete each post, and then remove any associated media files (attachments). Here's a complete script to achieve this:
<?php
// Load WordPress environment
require_once('/path/to/your/wp-load.php');
// Get all posts (any post type)
$args = array(
'post_type' => 'any', // 'any' retrieves all post types (posts, pages, custom post types)
'post_status' => 'any', // 'any' retrieves all post statuses
'posts_per_page' => -1, // Retrieve all posts
);
$all_posts = get_posts($args);
foreach ($all_posts as $post) {
// Get the post ID
$post_id = $post->ID;
// Check if the post has attachments (media files)
$attachments = get_attached_media('', $post_id);
// Delete each attachment associated with the post
foreach ($attachments as $attachment) {
$attachment_id = $attachment->ID;
// This deletes the file from the uploads directory and the database record
wp_delete_attachment($attachment_id, true);
}
// Delete the post itself
wp_delete_post($post_id, true); // true = force delete, bypass trash
}
echo 'All posts and their uploads have been deleted.';Oct 25, 2024
Read More Code
php
How To enable all error debugging in PHP
error_reporting(E_ALL);: Enables reporting for all levels of errors.ini_set('display_errors', 1);: Ensures that errors are displayed in the browser.- If you prefer to log the errors instead of displaying them, you can uncomment the
log_errorsanderror_loglines, specifying the path where errors should be logged.
Oct 25, 2024
Read MoreDiscussion 0
Please sign in to join the discussion.
No comments yet. Be the first to share your thoughts!