Skip to content

Instantly share code, notes, and snippets.

View mlbd's full-sized avatar
🏠
Working from home

Mohammad Limon mlbd

🏠
Working from home
View GitHub Profile
function wplap_get_attachment_id_from_url( $attachment_url = '' ) {
global $wpdb;
$attachment_id = false;
// If there is no url, return.
if ( '' == $attachment_url )
return;
// Get the upload directory paths
// image url
$image_url = 'http://yoursite.com/wp-content/uploads/2016/01/03/imageurl.jpg';
// retrive attachment ID
$id = wplap_get_attachment_id_from_url($image_url);
// display the ID
echo $id;
// get data form post meta
$dataMeta = get_post_meta( get_the_ID(), 'my-metafield', true );
// make sure your post meta isn't empty
if(!empty($dataMeta)) {
// image url
$image_url = $dataMeta;
// retrive attachment ID
class Excerpt {
// Default length (by WordPress)
public static $length = 55;
// So you can call: my_excerpt('short');
public static $types = array(
'short' => 25,
'regular' => 55,
'long' => 100
function wplap_increase_upload_limit( $size ) {
return 10000*800; //Size in Kb
}
add_filter( 'upload_size_limit', 'wplap_increase_upload_limit',12 );
function myfeed_request($request) {
if (isset($request['feed']))
$request['post_type'] = get_post_types();
return $request;
}
add_filter('request', 'myfeed_request');
<div id="registration_rom">
<?php
$err = '';
$success = '';
global $wpdb, $PasswordHash, $current_user, $user_ID;
if(isset($_POST['task']) && $_POST['task'] == 'register' ) {
add_action( 'show_user_profile', 'add_extra_social_links' );
add_action( 'edit_user_profile', 'add_extra_social_links' );
function add_extra_social_links( $user )
{
?>
<h3>New User Profile Links</h3>
<table class="form-table">
<tr>
function myfeed_request($qv) {
if (isset($qv['feed']) && !isset($qv['post_type']))
$qv['post_type'] = array('post', 'gadget', 'movies');
return $qv;
}
add_filter('request', 'myfeed_request');
UPDATE `wp_posts` SET `post_type` = 'NEW_POST_TYPE' WHERE `post_type` = 'OLD_POST_TYPE'