Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nashvillegeek/6353895 to your computer and use it in GitHub Desktop.
Save nashvillegeek/6353895 to your computer and use it in GitHub Desktop.
Wordpress Multisite switch blog and get archive Sublime Text 2 snippet
<snippet>
<content><![CDATA[
/* <?php */
global \$switched;
switch_to_blog(${1:1}); //input blog to switch to
// Get latest Post
\$latest_posts = get_posts('category=${2:-3}&numberposts=${3:5}&orderby=${4:post_name}&order=DSC');
?>
<ul>
<?php foreach(\$latest_posts as \$post) : setup_postdata(\$post);?>
<li><a href="<?php the_permalink(); ?>" title="<?php echo \$post->post_title; ?>"><?php the_post_thumbnail(); ?></a>
<a href="<?php the_permalink(); ?>" title="<?php echo \$post->post_title; ?>"><?php echo \$post->post_title; ?></a>
<p><?php the_excerpt(); ?></p>
</li>
<?php endforeach ; ?>
</ul>
<?php restore_current_blog(); //switched back to main site
/* ?> */
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>wpswitchtoblogpost</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment