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 | |
$myposts = get_posts('category_name=carros&posts_per_page=1'); //exemplo de um post da categoria "Carros" | |
$r = wp_list_pluck( $myposts, 'ID' ); //no caso ID, pode ser outros campos | |
echo 'O ID do post:'.$r[0]; //usar [0] |
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_filter('oembed_result','twitter_no_width',10,3); | |
function twitter_no_width($html, $url, $args) { | |
if (false !== strpos($url, 'twitter.com')) { | |
$html = str_replace('width="550"','',$html); | |
} | |
return $html; | |
} |
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 the_category_filter($thelist,$separator=' ') { | |
if(!defined('WP_ADMIN')) { | |
$exclude = array('Blog'); /* nomes/slugs da cats */ | |
$cats = explode($separator,$thelist); | |
$newlist = array(); | |
foreach($cats as $cat) { |
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_filter('body_class','my_class_names'); | |
function my_class_names($classes) { | |
$classes[] = 'page-'.get_query_var('pagename'); | |
// return the $classes array | |
return $classes; | |
} |
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 replace_text_wps($text){ | |
$replace = array( | |
// 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS' | |
'thesis' => '<a href="http://mysite.com/myafflink">thesis</a>', | |
'studiopress' => '<a href="http://mysite.com/myafflink">studiopress</a>' | |
); | |
$text = str_replace(array_keys($replace), $replace, $text); | |
return $text; |
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 | |
$parent_title = get_the_title($post->post_parent); | |
echo $parent_title; | |
?> |
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_filter( 'image_size_names_choose', 'custom_image_sizes_choose' ); | |
function custom_image_sizes_choose( $sizes ) { | |
$custom_sizes = array( | |
'featured-image' => 'Featured Image' | |
); | |
return array_merge( $sizes, $custom_sizes ); | |
} |
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 | |
// make category use parent category template | |
function load_cat_parent_template($template) { | |
$cat_ID = absint( get_query_var('cat') ); | |
$category = get_category( $cat_ID ); | |
$templates = array(); |
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_action( 'init', 'wpse17478_init' ); | |
function wpse17478_init() | |
{ | |
remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' ); | |
} | |
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_action( 'admin_footer-post.php', 'wpse_22836_remove_top_categories_checkbox' ); | |
add_action( 'admin_footer-post-new.php', 'wpse_22836_remove_top_categories_checkbox' ); | |
function wpse_22836_remove_top_categories_checkbox() | |
{ | |
global $post_type; | |
if ( 'post' != $post_type ) |