Skip to content

Instantly share code, notes, and snippets.

View wpexplorer's full-sized avatar
✍️
We create themes & plugins and run a popular blog about WordPress.

WPExplorer wpexplorer

✍️
We create themes & plugins and run a popular blog about WordPress.
View GitHub Profile
@wpexplorer
wpexplorer / gist:8657325
Last active January 6, 2019 20:54
Sample Custom Post Type WP_Query
global $post,$paged;
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$display_count = '10';
$wpex_query = new WP_Query(
array(
'post_type' => 'portfolio',
'posts_per_page => $display_count,
'paged' => $paged
)
);
@wpexplorer
wpexplorer / gist:8682239
Created January 29, 2014 05:16
Portfolio Post Type Archive & Taxonomy Order
function wpex_order_portfolio( $query ) {
// exit out if it's the admin or it isn't the main query
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
// order portfolio archive by title in ascending order
if ( is_post_type_archive( 'portfolio' ) ) {
$query->set( 'order' , 'asc' );
$query->set( 'orderby', 'title');
return;
@wpexplorer
wpexplorer / gist:8682705
Created January 29, 2014 06:03
Office Theme Contact Page
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget sapien libero, nec scelerisque urna. In mi ante, iaculis sed sollicitudin id, egestas sit amet lacus. Donec adipiscing dolor eget eros porttitor in aliquet est pharetra. This is just your regular post content, obviously you can put anything you want here and the double border below is the hr shortcode.
[hr]
[column size="half" position="first"]
[contact-form-7 id="303" title="Untitled"]
[/column]
@wpexplorer
wpexplorer / gist:9608772
Created March 17, 2014 21:29
Alter fabulous featured image to link to itself
function wpex_post_featured_image() {
global $post;
if ( !has_post_thumbnail( $post->ID ) ) return;
if ( !get_theme_mod( 'wpex_blog_post_thumb', '1' ) ) return;
if ( 'on' == get_post_meta( $post->ID, 'wpex_disable_featured_image', true ) ) return; ?>
<div class="post-thumbnail">
<a href="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>" title="View Full Image"><img src="<?php echo wpex_get_featured_img_url(); ?>" alt="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" /></a>
</div><!-- .post-thumbnail -->
<?php
} // End function
@wpexplorer
wpexplorer / wordpress-attachments-search
Created March 20, 2014 01:21
Include Attachments in WordPress Search Results
@wpexplorer
wpexplorer / wordpress-remove-post-type-slug
Last active October 7, 2022 01:27
Remove Custom Post Type Slug
<?php
/**
* Remove the slug from published post permalinks for our custom post types.
*/
add_filter( 'post_type_link', function( $post_link, $post, $leavename ) {
$post_types = array(
'post_type_1',
'post_type_2'
);
@wpexplorer
wpexplorer / gist:9745941
Created March 24, 2014 18:17
Fabulous Display Sidebar on Homepage Always
if ( ! function_exists( 'wpex_sidebar_display' ) ) {
function wpex_sidebar_display() {
if ( is_front_page() ) return true; // Display sidebar on homepage no matter what.
if ( is_singular() ) {
global $post;
$post_layout = get_post_meta( $post->ID, 'wpex_post_layout', true );
if ( '' == $post_layout ) return true;
if ( 'right-sidebar' == $post_layout || 'left-sidebar' == $post_layout ) {
return true;
@wpexplorer
wpexplorer / wordpress-featured-image-alt
Created March 24, 2014 19:44
WordPress Featured Image Alt
@wpexplorer
wpexplorer / total-remove-portfolio-slug
Last active August 29, 2015 13:57
Remove Portfolio Slug From Total Theme
//Remove the slug from portfolio post type
function vipx_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( ! in_array( $post->post_type, array( 'portfolio' ) ) || 'publish' != $post->post_status )
return $post_link;
$post_link = str_replace( '/'. wpex_option('portfolio_slug','portfolio-item') .'/', '/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'vipx_remove_cpt_slug', 10, 3 );
function vipx_parse_request_tricksy( $query ) {
// Only noop the main query
<FilesMatch ".(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>