This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function load_more_scripts() { | |
wp_enqueue_script( 'load-more', get_stylesheet_directory_uri() . '/js/load-more.js', array('jquery'), '1.0', true ); | |
wp_localize_script( 'load-more', 'load_more_params', array( | |
'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), | |
'security' => wp_create_nonce( 'load_more_security' ), | |
)); | |
} | |
add_action( 'wp_enqueue_scripts', 'load_more_scripts' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function load_more_scripts() { | |
wp_enqueue_script( 'load-more', get_stylesheet_directory_uri() . '/js/load-more.js', array('jquery'), '1.0', true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'load_more_scripts' ); | |
function load_more_posts() { | |
check_ajax_referer( 'load_more_security', 'security' ); | |
$paged = $_POST['page']; | |
$post_type = isset($_POST['post_type']) ? $_POST['post_type'] : 'post'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<?php | |
// Get current page ID and sanitize the input data | |
$page_id = absint(get_queried_object_id()); | |
// Define image URLs for each page ID (using HTTPS) | |
$banner_images = array( | |
1 => 'https://example.com/banner-1.jpg', | |
2 => 'https://example.com/banner-2.jpg', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add a new metabox to the testimonial post type | |
function add_testimonial_metabox() { | |
// Use the WordPress function add_meta_box to define our metabox | |
add_meta_box( | |
'testimonial_metabox', // Metabox ID | |
'Testimonial Details', // Metabox title | |
'render_testimonial_metabox', // Callback function to render the metabox contents | |
'testimonial', // Post type where the metabox should appear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function display_encrypted_contact_form() { | |
// Initialize variables | |
$errors = array(); | |
$success = false; | |
// Check if form was submitted | |
if ($_SERVER["REQUEST_METHOD"] == "POST") { | |
// Validate nonce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mytheme_enqueue_scripts() { | |
wp_enqueue_style( 'mytheme-style', get_stylesheet_uri() ); | |
// Check if we're in a local development environment or accessing from localhost | |
if ( 'local' === wp_get_environment_type() || in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')) ) { | |
// Enqueue the local development version of the script over HTTP | |
wp_enqueue_script( 'mytheme-scripts', 'http://localhost:8080/bundle.js', array(), '1.0.0', true ); | |
} elseif ( WP_DEBUG ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
a general overview of how to create a WordPress metabox that establishes a relationship between two custom post types and shares | |
details between them both, then output the data to the front end. | |
You will need to first register your custom post types using the register_post_type() function in your WordPress theme's functions.php | |
file. | |
Create a metabox for one of the custom post types using the add_meta_box() function. Within the metabox callback function | |
you can use the metadata API to retrieve data related to the other custom post type. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
To create a relationship metabox between two custom post types in WordPress, you'll need to use the add_meta_box() function | |
and the WP_Query class. Here are the steps you can follow: | |
Create a custom post type using the register_post_type() function for both post types. | |
In the functions.php file of your theme or plugin, add the following code to create a metabox: | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Validate and sanitize the ID of the current post | |
$portfolio_id = ( isset( $_GET['post'] ) && ctype_digit( $_GET['post'] ) ) ? $_GET['post'] : ''; | |
$portfolio_id = filter_var( $portfolio_id, FILTER_SANITIZE_NUMBER_INT ); | |
// Verify the nonce before processing the form submission | |
if ( isset( $_POST['submit_related_portfolio'] ) && wp_verify_nonce( $_POST['related_portfolio_nonce'], 'related_portfolio' ) ) { | |
// Sanitize the input data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
The purpose of this field is to allow you to enter a custom URL for an image, which can be used as the featured image for your | |
WordPress post or page. This could be useful if you have an image that you want to use as the featured image, but it is not hosted | |
on your own website and therefore cannot be easily uploaded through the WordPress media library. | |
By adding this custom field, you can enter the URL of the external image and then use it as the featured image for your post or page, | |
just as you would with a standard image uploaded through the WordPress media library. | |
*/ |
NewerOlder