Skip to content

Instantly share code, notes, and snippets.

View MrJSdev's full-sized avatar
🎯
Loading JS

Riyaz Khan MrJSdev

🎯
Loading JS
View GitHub Profile
@MrJSdev
MrJSdev / single.php
Created March 27, 2018 05:12
To check Single attachment post id: http://extracatchy.net/if-post-id/
<?php
// Do not copy the above php tag.
if( is_attachment( 1780 ) ) {
/* do something... */
} else {
/* ... */
}
@MrJSdev
MrJSdev / single.php
Created March 27, 2018 05:11
This is the simple code for the guide: http://extracatchy.net/if-post-id/
<?php
// Do not copy the above php tag.
if( is_page( 1780 ) ) {
/* Do something... */
} else {
/* ... */
}
@MrJSdev
MrJSdev / single.php
Created March 27, 2018 05:08
This is the simple code for the guide: http://extracatchy.net/if-post-id/
<?php
// Do not copy the above php tag.
if( is_single( 1780 ) ) {
/* ... */
} else {
/* ... */
}
<?php
global $wp_query;
echo $wp_query->post->ID;
?>
@MrJSdev
MrJSdev / page.php
Last active September 25, 2021 11:39
This is the code for the guide: http://extracatchy.net/wordpress-functions
<?php
global $post;
echo $post->ID;
?>
<form method=”get” action=”<?php bloginfo(‘home’); ?>/”>
<input type=”hidden” name=”cat” id=”cat” value=”8″ /> <!-- cahnge category value to your category id -->
<input type=”text” size=”14″ name=”s” value=”Search” />
<input type=”submit” value=”Search” />
</form>
<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
<div class="form-group">
<div class="input-group">
<input type="search" class="form-control form-input"
placeholder="<?php echo esc_attr_x( 'Search for T-Shirts…', 'placeholder' ) ?>"
value="<?php echo get_search_query() ?>" name="s"
title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" />
<input type="hidden" name="post_type" value="t-shirts" /> <!-- Change value from "t-shirts" to whatever your custom post type name -->
<div class="input-group-addon"><button class="form-btn" ><i class="fa fa-search" aria-hidden="true"></i></button></div>
</div>
<?php
// Do not copy the opening php tag.
/*
*@title: Search only Post or Pages
*@link: http://extracatchy.net/wordpress-limit-search-results/
*/
function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type',array('post','page'));
@MrJSdev
MrJSdev / .htaccess
Last active September 25, 2021 11:39
This is the guide for the code: http://extracatchy.net/wordpress-functions
<files wp-config.php>
order allow,deny
deny from all
</files>
<?php
/* Do not copy the opening php tag */
/*
@title: Load Jquery in Footer
@link: http://extracatchy.net/load-jquery-in-footer/
*/
function jquery_in_footer($scripts) {
if ( ! is_admin() )