Created
December 12, 2018 17:34
-
-
Save sDLme/2afd80559b5e7b3b1e2ff5109f6df352 to your computer and use it in GitHub Desktop.
Job & sharing btn
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 create_job_posttype() { | |
register_post_type( 'job', | |
array( | |
'labels' => array( | |
'name' => __( 'Jobs' ), | |
'singular_name' => __( 'Job' ) | |
), | |
'public' => true, | |
'has_archive' => false, | |
'rewrite' => array('slug' => 'wanted'), | |
) | |
); | |
} | |
add_action( 'init', 'create_job_posttype' ); | |
/* | |
* Sharing shortcode for job custom post type [sharing] | |
*/ | |
function sharing_func( ){ | |
ob_start(); | |
$url = $_SERVER['HTTP_HOST']; | |
$str = strtolower(get_the_title()); | |
$title = preg_replace('/\s+/', '-', $str); | |
?> | |
<!-- Share panel --> | |
<div class="share-panel"> | |
<p class="share-panel__share-label">You fit the part? C’mon, drop us a line. Not for you? share it on</p> | |
<ul class="share-panel__share-list"> | |
<li class="share-list__share-item"> | |
<a class="share-item__share-link" | |
target="_blank" | |
href="https://www.facebook.com/sharer/sharer.php?u=https://<?php echo $url . '/wanted/' .$title ?>"> | |
<img class="share-item__share-icon" | |
src="<?php echo get_stylesheet_directory_uri() ?>/imgs/facebook.svg" | |
alt="Icon"> | |
</a> | |
</li> | |
<li class="share-list__share-item"> | |
<a href="https://www.linkedin.com/shareArticle?mini=true&url=https://<?php echo $url . '/wanted/' .$title ?>&title=Perelview%20Job&summary=Perelview%20Job&source=https://<?php echo $url . '/wanted/' .$title ?>" | |
target="_blank" | |
class="share-item__share-link"> | |
<img src="<?php echo get_stylesheet_directory_uri() ?>/imgs/linkedin.svg" | |
alt="Icon" | |
class="share-item__share-icon"> | |
</a> | |
</li> | |
<li class="share-list__share-item"> | |
<a href="whatsapp://send?text=https://<?php echo $url . '/wanted/' .$title ?>" data-action="share/whatsapp/share" | |
target="_blank" | |
class="share-item__share-link"> | |
<img src="<?php echo get_stylesheet_directory_uri() ?>/imgs/whatsapp.svg" | |
alt="Icon" | |
class="share-item__share-icon"> | |
</a> | |
</li> | |
</ul> | |
</div><!-- End of Share panel --> | |
<?php | |
return ob_get_clean(); | |
} | |
add_shortcode('sharing', 'sharing_func'); | |
/* | |
* Shortcode for displaing job custom post type | |
*/ | |
function jobs_show() { | |
ob_start(); | |
$args = array( | |
'post_type' => 'job', | |
'post_status'=> 'publish', | |
'posts_per_page' => -1, | |
'order'=> 'DESC' | |
); | |
$the_query = new WP_Query( $args ); | |
// The Loop | |
if ( $the_query->have_posts() ) :?> | |
<div class="jobs-panel"> | |
<?php | |
while ( $the_query->have_posts() ) : $the_query->the_post();?> | |
<h2 class="jobs-panel__title accordion"><?php echo the_title(); ?></h2> | |
<div class="jobs-panel__content panel"> | |
<?php | |
echo the_content(); | |
?> | |
</div> | |
<?php | |
endwhile; | |
?> | |
</div> | |
<?php | |
endif; | |
wp_reset_postdata(); | |
return ob_get_clean(); | |
} | |
add_shortcode('jobs','jobs_show'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment