Public
snipts » wordpress
showing 1-20 of 98 snipts for wordpress
-
∞ Set a WP pass from mysql shell
UPDATE wp_users SET user_pass = MD5('newpassword') WHERE user_login = "admin";
-
∞ Returns the number of results
<?php echo $wp_query->found_posts; ?>
-
∞ Returns the searched keyword
<?php echo get_search_query(); ?>
-
∞ add a msg in wp admin..
<?php function my_admin_msg($text) { $text="hi.."; echo '<div id="update-nag">'.$text.'</div>'; } add_action( 'admin_notices', 'my_admin_msg', 4 ); ?>
-
∞ Return a class is a certain page template is used
<?php function page_template_class() { $page_template_class = ''; if (is_page_template('kinderen.php')) { $page_template_class = 'kinderen'; } if (!empty($page_template_class)) { echo ' class="'.$page_template_class.'"'; } else { return false; } } ?>
-
∞ Show custom field only if populated
<?php $FIELDNAME = get_post_meta($post->ID, 'FIELDNAME', true); if($FIELDNAME) : ?> <a title="Click Here To Purchase Tickets" href="<?php get_custom_field_value('FIELDNAME', true) ?>" rel="bookmark">PURCHASE TIX</a> <?php endif; ?>
-
∞ Replace the output of wp_list_pages();
<?php $page_output = wp_list_pages('echo=0&title_li=&sort_column=menu_order&depth=1&include='.$page_ids); $page_output = preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<li$1><a$2><span>$3</span></a>', $page_output); echo $page_output; ?>
-
∞ Get the nth sentence from the post (beta)
<?php function the_nth_sentence($sentence_num = 1) { if ($sentence_num == 0) { return false; } if ($sentence_num >= 1) { $sentence_num = $sentence_num-1; } $content = get_the_content('',FALSE,''); $content = apply_filters('the_content', $content); $content = strip_tags($content); $pos = strpos($content, '.'); for($i=1; $i<=$sentence_num; $i++) { $pos = strpos($content, '.', $pos+1); } echo '<p>' . substr($content,0,$pos+1) . '</p>'; } ?>
-
∞ Get the first sentence of the post
<?php function the_first_sentence() { $content = get_the_content('',FALSE,''); $content = apply_filters('the_content', $content); $content = strip_tags($content); $pos = strpos($content, '.'); echo '<p>' . substr($content,0,$pos+1) . '</p>'; } ?>
-
∞ Backup index.php Super45.net
<?php get_header(); ?> <div id="row1"> <div id="discodestacado"> <h2><img src="/images/disco-destacado.png" alt="Disco Destacado" /></h2> <div id="contenedor-disco"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=1488'); ?> <?php while (have_posts()) : the_post(); ?> <div id="foto-tit-dd"> <div id="fotodd"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div id="titdd"><h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3></div> </div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> </div><!-- end of discodestacado div --> <div id="otrosdiscos"> <h2><img src="/images/en-breve.png" alt="En Breve" /></h2> <div id="slider"> <ul> <li> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=6&cat=1489'); ?> <?php while (have_posts()) : the_post(); ?> <div class="d-breve"><div class="foto-breve"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div><div class="tit-breve"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></div></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </li> <li> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=6&offset=6&cat=1489'); ?> <?php while (have_posts()) : the_post(); ?> <div class="d-breve"><div class="foto-breve"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div><div class="tit-breve"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></div></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </li> <li> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=6&offset=12&cat=1489'); ?> <?php while (have_posts()) : the_post(); ?> <div class="d-breve"><div class="foto-breve"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div><div class="tit-breve"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></div></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </li> </ul> </div> </div><!-- end of otrosdiscos div --> <div id="publi1"> <script type='text/javascript'><!--//<![CDATA[ var m3_u = (location.protocol=='https:'?'https://open.estupendos.net/www/delivery/ajs.php':'http://open.estupendos.net/www/delivery/ajs.php'); var m3_r = Math.floor(Math.random()*99999999999); if (!document.MAX_used) document.MAX_used = ','; document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u); document.write ("?zoneid=2"); document.write ('&cb=' + m3_r); if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used); document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : '')); document.write ("&loc=" + escape(window.location)); if (document.referrer) document.write ("&referer=" + escape(document.referrer)); if (document.context) document.write ("&context=" + escape(document.context)); if (document.mmm_fo) document.write ("&mmm_fo=1"); document.write ("'><\/scr"+"ipt>"); //]]>--></script><noscript><a href='http://open.estupendos.net/www/delivery/ck.php?n=a75a6856&cb=23544353' target='_blank'><img src='http://open.estupendos.net/www/delivery/avw.php?zoneid=2&cb=23544353&n=a75a6856' border='0' alt='' /></a></noscript> </div><!-- end of publi1 div --> </div><!-- end of row1 div --> <div id="row2"> <div id="destacado"> <h2><img src="/images/destacamos.png" alt="Destacamos en S45" /></h2> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=1509'); ?> <?php while (have_posts()) : the_post(); ?> <div id="contenedor-destacado"> <div class="foto-destacado"><?php get_the_image('custom_key=foto-home&default_size=full&default_image=/images/medium.png'); ?></div> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php foreach((get_the_category()) as $cat) { if ($cat->cat_ID != "1509" ) { echo '<a href="/?cat=' . $cat->cat_ID . '"> ' . $cat->cat_name . '</a> '; } } ?> | Por <?php the_author_posts_link(); ?> | <?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=5&offset=1&cat=1509'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php foreach((get_the_category()) as $cat) { if ($cat->cat_ID != "1509" ) { echo '<a href="/?cat=' . $cat->cat_ID . '"> ' . $cat->cat_name . '</a> '; } } ?> | <?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div><!-- end of destacado div --> <div id="articulos"> <ul> <li><a href="#tabs-1"><img src="/images/blog.png" alt="Blog" /></a></li> <li><a href="#tabs-2"><img src="/images/noticias.png" alt="Noticias" /></a></li> <li><a href="#tabs-3"><img src="/images/articulos.png" alt="Articulos" /></a></li> </ul> <div id="tabs-1"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=8&cat=41'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <div class="vertodos"><a href="/seccion/blog/" title="Ver todo el blog">[+] Ver todos</a></div> </div> <div id="tabs-2"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=8&cat=3'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <div class="vertodos"><a href="/seccion/noticias/" title="Ver todas las noticias">[+] Ver todos</a></div> </div> <div id="tabs-3"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=42'); ?> <?php while (have_posts()) : the_post(); ?> <div id="contenedor-articulo"> <div class="contenedor-foto-articulo"><?php get_the_image('custom_key=foto-home&default_size=full&default_image=/images/medium.png'); ?></div> <div class="cat-arti"><?php the_category(); ?></div> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata">Por <?php the_author_posts_link(); ?> | <?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=5&offset=1&cat=42,44,45'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="cat-arti"><?php the_category(); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <div class="vertodos"><a href="/seccion/articulos/" title="Ver todos los artículos">[+] Ver todos</a></div> </div> </div><!-- end of articulos div --> <div id="radio"> <div id="s45radio"> <h2><img src="/images/2009/06/super-45-radio.png" alt="S45 en Radio Duna" /></h2> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=49'); ?> <?php while (have_posts()) : the_post(); ?> <div id="foto-radio"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div id="txt-radio"> <span class="prox-radio">Próximo programa:<br /></span> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <?php the_excerpt() ?> </div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <div class="podcast"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=21'); ?> <?php while (have_posts()) : the_post(); ?> <div id="txt-podcast"> <p class="podcast-anterior">Descarga el programa anterior:</p> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <div class="excerpt-podcast"><?php the_excerpt() ?></div> </div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> </div> <div id="ad-radio1"></div> <div id="agenda"> <ul> <li><a href="#tabs-4"><img src="/images/nuestra_agenda.png" alt="Nuestra Agenda" /></a></li> <li><a href="#tabs-5"><img src="/images/cartelera.png" alt="Cartelera" /></a></li> <li><a href="#tabs-6"><img src="/images/concursos.png" alt="Concursos" /></a></li> </ul> <div id="tabs-4"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=2&cat=1511'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> <div id="tabs-5"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=35'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado25"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> <div id="tabs-6"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=66'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado2"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=2&offset=1&cat=66'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-concurso"> <div class="txt-sub-concurso"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> </div><!-- end of agenda div --> <div id="ad-radio2"><a href="http://sonik.cl"><img src="/images/300x100-Sonik-S45.gif" alt="Sonik" /></a></div> <div id="ad-radio3"> <script type='text/javascript'><!--//<![CDATA[ var m3_u = (location.protocol=='https:'?'https://open.estupendos.net/www/delivery/ajs.php':'http://open.estupendos.net/www/delivery/ajs.php'); var m3_r = Math.floor(Math.random()*99999999999); if (!document.MAX_used) document.MAX_used = ','; document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u); document.write ("?zoneid=5"); document.write ('&cb=' + m3_r); if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used); document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : '')); document.write ("&loc=" + escape(window.location)); if (document.referrer) document.write ("&referer=" + escape(document.referrer)); if (document.context) document.write ("&context=" + escape(document.context)); if (document.mmm_fo) document.write ("&mmm_fo=1"); document.write ("'><\/scr"+"ipt>"); //]]>--></script><noscript><a href='http://open.estupendos.net/www/delivery/ck.php?n=a5a9a894&cb=5467546' target='_blank'><img src='http://open.estupendos.net/www/delivery/avw.php?zoneid=5&cb=5467546&n=a5a9a894' border='0' alt='' /></a></noscript> </div> <div id="tla"><?php tla_ads(); ?><br/><?php if (is_callable(array("LinkLiftPlugin", "execute"))) LinkLiftPlugin::execute(); ?></div> </div><!-- end of radio div --> </div><!-- end of row2 div --> <div id="row3"> <h2>Comunidad Super 45</h2> <div id="eventos"> <h3><a href="http://vimeo.com/super45">Noa Noa</a></h3> <div class="videos-oficiales"> <!-- START Vimeo Badge ... info at http://vimeo.com/widget --> <div class="vimeoBadge"> <script type="text/javascript" src="http://vimeo.com/super45/badgeo/?stream=uploaded&stream_id=&count=4&thumbnail_width=100&show_titles=no"></script> </div> <!--END Vimeo Badge--> </div> </div><!-- end of eventos div --> <div id="vimeo"> <h3><a href="http://vimeo.com/channels/super45">Canal Vimeo</a></h3> <!-- START Vimeo Badge ... info at http://vimeo.com/widget --> <div class="vimeoBadge"> <script type="text/javascript" src="http://vimeo.com/super45/badgeo/?stream=channel&stream_id=34616&count=6&thumbnail_width=100&show_titles=no"></script> </div> <!--END Vimeo Badge--> </div><!-- end of vimeo div --> <div id="flickr"> <h3><a href="http://www.flickr.com/super45/">Super 45 en Flickr</a></h3> <div id="contenedor-flickr"> <!-- Start of Flickr Badge --> <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=5&display=latest&size=s&layout=x&source=user&user=39096086%40N04"></script> <!-- End of Flickr Badge --> </div> </div><!-- end of flickr div --> <div id="sociales"> <ul> <li><a class="facebook" href="http://facebook.com/group.php?gid=13967200331">Grupo Facebook</a></li> <li><a class="facebook" href="http://facebook.com/pages/Santiago-Chile/Super-45/14050945943">Página Facebook</a></li> <li><a class="twitter" href="http://twitter.com/super45">Twitter</a></li> <li><a class="lastfm" href="http://last.fm/group/Super+45">Grupo Last.fm</a></li> </ul> </div><!-- end of sociales div --> </div><!-- end of row3 div --> <?php get_footer(); ?>
-
∞ Redirect to Primary Blog
<?php /* Plugin Name: Redirect to Primary Blog */ // redirect to primary blog function redirect_to_primary_blog() { if(!is_site_admin()){ global $current_user; get_currentuserinfo(); $blog_details = get_blog_details(get_usermeta($current_user->ID,'primary_blog')); if($_SERVER['HTTP_HOST'] != $blog_details->domain){ header( 'Location: http://'.$blog_details->domain.'/wp-admin/'); } } } add_action('admin_init', 'redirect_to_primary_blog'); ?>
-
∞ wordpress mu embed import
'object' => array ( 'id' => array (), 'classid' => array (), 'data' => array (), 'type' => array (), 'width' => array (), 'height' => array (), 'allowfullscreen' => array ()), 'param' => array ( 'name' => array (), 'value' => array ()), 'embed' => array ( 'id' => array (), 'style' => array (), 'src' => array (), 'type' => array (), 'height' => array (), 'width' => array (), 'quality' => array (), 'name' => array (), 'flashvars' => array (), 'allowscriptaccess' => array (), 'allowfullscreen' => array ()), 'script' => array ( 'type' => array ()),
-
∞ Cambiar un valor por otro en una base de datos MySQL
UPDATE wp_postmeta SET meta_value=(REPLACE (meta_value, '/home/.filofax/super45/super45.cl/images/', ''));
-
∞ Como hacer un listado de categorías en Wordpress, excluyendo algunas
<?php foreach((get_the_category()) as $cat) { if ($cat->cat_ID != "60" ) if ($cat->cat_ID != "70" ) if ($cat->cat_ID != "71" ) if ($cat->cat_ID != "72" ) { echo '<a href="/?cat=' . $cat->cat_ID . '"> ' . $cat->cat_name . '</a> '; } } ?>
-
∞ Loop para listar hijos de un page de Wordpress
<?php $paginas = get_pages('child_of=1'); ?> <?php foreach($paginas as $pagina): ?> <?php if (have_posts()) : ?> <?php query_posts("page_id=$pagina->ID"); ?> <?php while (have_posts()) : the_post(); ?> <?php the_content('Read the rest of this entry »'); ?> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <?php wp_reset_query(); ?> <?php endforeach; ?>
-
∞ como crear un loop
<?php query_posts(array('category_name' => 'qwerty', 'posts_per_page' => 5)); if (have_posts()): while(have_posts()): the_post(): ?> // el contenido <?php else: ?> no existe nada <?php endif; endwhile; ?>
-
∞ Easily get the value of a custom field
ADD TO Functions.php function get_custom_field_value($szKey, $bPrint = false) { global $post; $szValue = get_post_meta($post->ID, $szKey, true); if ( $bPrint == false ) return $szValue; else echo $szValue; } ADD TO Theme : <?php if ( function_exists('get_custom_field_value') ){ get_custom_field_value('featured_image', true); } ?>
-
∞ Sort Order by Custom Field for specific Category
<?php if (is_category('26')) { $posts = query_posts($query_string. '&orderby=meta_value&meta_key=date&order=DESC' ); } ?>
-
∞ functions for categories
<?php // find current category id on category page $cat = get_query_var('cat'); // category name from id get_cat_name( $catid ); // category link from id get_category_link( $catid ); // category id from name or slug $cat_idaa = get_cat_ID( $cat_slug ); ?>
-
∞ Exclude array of categories
<?php function exclude_categories(array $categories, $sign = TRUE) { $exclude_cat = new WP_Query('showposts=0'); if ($sign == TRUE): $sign = "-"; else: $sign = ""; endif; foreach((get_categories()) as $cat): if(in_array($cat->cat_name, $categories)): $exclude_id .= $sign . $cat->cat_ID .','; endif; endforeach; $exclude_id = substr($exclude_id, 0, -1); return $exclude_id; } ?>



MySQL (4th Edition) (Developer's Library)