Skip to content

Instantly share code, notes, and snippets.

@domantasg
domantasg / delete_wp_posts.py
Last active February 18, 2023 19:43
Delete WordPress posts with less than 10 impressions in Google Search Console
import requests
import base64
from tqdm import tqdm
import pandas as pd
from datetime import datetime, timedelta
import searchconsole
domain = "" # Must have trailing slash!
# WordPress Logins
<h3>Video Tutorial</h3>
<div class="video-container">
<iframe src="YOUTUBE_EMBED_URL_GOES_HERE"></iframe>
</div>
<?php
if( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ){
$current_site = new stdClass;
$current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? constant( 'SITE_ID_CURRENT_SITE' ) : 1;
$current_site->domain = $domain = DOMAIN_CURRENT_SITE;
$current_site->path = $path = PATH_CURRENT_SITE;
if( defined( 'BLOGID_CURRENT_SITE' ) ){
$current_site->blog_id = BLOGID_CURRENT_SITE;
}
$url = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}
<?php
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
/ Hook our custom function to the pre_get_posts action hook
add_action( 'pre_get_posts', 'add_reviews_to_frontpage' );
// Alter the main query
function add_reviews_to_frontpage( $query ) {
if ( is_home() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post', 'movie', 'review' ) );
}
return $query;
}
// Display field value
the_field( 'FIELD NAME' );
// Return field value
get_field( 'FIELD NAME' );
<?php
$movie_box_art = get_post_meta( $post->ID, 'Box Art', TRUE );
if (!empty($movie_box_art)) { ?>
<div class="movie-poster-box">
<img src="<?php echo $movie_poster ?>" alt="<?php single_post_title(); ?> ">
</div>
<? } ?>
<ul class='post-meta'>
<li>
<span class='post-meta-key'>{your_key}</span> {your_value}
</li>
</ul>
// Generates all custom fields attached to the post in a <ul> list
the_meta();
// Get a specific piece of information
echo get_post_meta( $post->ID, 'Budget', TRUE );