This file contains hidden or 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 test_shortcode($atts, $content = null){ | |
extract( shortcode_atts( array( | |
'expand' => '', | |
), $atts) ); | |
$q = new WP_Query( | |
array('posts_per_page' =>'9', 'post_type' =>'service') | |
); | |
This file contains hidden or 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
register nav menu | |
<?php | |
function moderna_manus(){ | |
register_nav_menus(array( | |
'main_menu' => 'Main Menu' | |
)); |
This file contains hidden or 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 wishlist_shortcode($atts){ | |
extract( shortcode_atts( array( | |
'expand' => '', | |
), $atts, 'wishlist' ) ); | |
$q = new WP_Query( | |
array('posts_per_page' => '4', 'post_type' => 'wishlist-items', 'meta_key' => 'order_number','orderby' => 'meta_value','order' => 'ASC') | |
); |
This file contains hidden or 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
Custom-posts-global-query | |
<?php | |
global $post; | |
$args = array( 'posts_per_page' => -1, 'post_type'=> 'posttype', 'orderby' => 'menu_order', 'order' => 'ASC' ); | |
$myposts = get_posts( $args ); | |
foreach( $myposts as $post ) : setup_postdata($post); ?> | |
<?php | |
$job_link= get_post_meta($post->ID, 'job_instructions', true); |
This file contains hidden or 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 the_author(); ?> | |
<?php echo get_avatar( get_the_author_email(), 'size here' ); ?> | |
<?php echo the_author_link(); ?> | |
<?php the_author_posts_link(); ?> | |
<?php the_author_meta( $field, $userID ); ?> | |
<?php the_author_meta('twitter'); ?> | |
<?php the_author_description(); ?> | |
<?php echo date("D M Y", strtotime(get_userdata(get_current_user_id( ))->user_registered)); ?> | |
This file contains hidden or 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 | |
wp_enqueue_script('jquery'); | |
if (!function_exists('load_theme_scripts')) { | |
function load_theme_scripts(){ | |
wp_enqueue_script( 'custom-script', get_template_directory_uri() . '/js/custom.js', array('jquery'), '1.0.0', true ); | |
} | |
add_action("wp_enqueue_scripts", "load_theme_scripts"); | |
} | |
?> |
This file contains hidden or 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
Category name(‘shirt’, ‘tshirt’, ‘pant’) which not to want display products on the shop page | |
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' ); | |
function custom_pre_get_posts_query( $q ) { | |
if ( ! $q->is_main_query() ) return; | |
if ( ! $q->is_post_type_archive() ) return; | |
This file contains hidden or 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
Redirect to custom page when user logged in | |
function login_redirect( $redirect_to, $request, $user ){ | |
return home_url('custom-page-url-extension'); | |
//Custom page url extension where want redirect | |
} | |
add_filter( 'login_redirect', 'login_redirect', 10, 3 ); |
This file contains hidden or 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
Use in theme functions.php file | |
function get_related_author_posts() { | |
global $authordata, $post; | |
$authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) ); | |
$output = '<ul>'; | |
foreach ( $authors_posts as $authors_post ) { | |
$output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>'; | |
} |
This file contains hidden or 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 | |
$tags = get_terms( array("post_tag"), array("orderby"=>"count","order"=>"DESC")); | |
if ( !empty( $tags ) && !is_wp_error( $tags ) ) : | |
echo '<ul>'; | |
foreach ( $tags as $tag ) : | |
echo '<li>' . $tag->name . '(' . $tag->count . ')</li>'; | |
endforeach; | |
echo '</ul>'; | |
endif; |