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
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 |
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
// 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; |
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
// 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 |
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
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 |
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
function wplap_increase_upload_limit( $size ) { | |
return 10000*800; //Size in Kb | |
} | |
add_filter( 'upload_size_limit', 'wplap_increase_upload_limit',12 ); |
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
function myfeed_request($request) { | |
if (isset($request['feed'])) | |
$request['post_type'] = get_post_types(); | |
return $request; | |
} | |
add_filter('request', 'myfeed_request'); |
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
<div id="registration_rom"> | |
<?php | |
$err = ''; | |
$success = ''; | |
global $wpdb, $PasswordHash, $current_user, $user_ID; | |
if(isset($_POST['task']) && $_POST['task'] == 'register' ) { | |
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
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> |
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
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'); |
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
UPDATE `wp_posts` SET `post_type` = 'NEW_POST_TYPE' WHERE `post_type` = 'OLD_POST_TYPE' |
OlderNewer