Skip to content

Instantly share code, notes, and snippets.

View Ozzy182's full-sized avatar
💭

Ozosh Maharjan Ozzy182

💭
  • Kathmandu, Nepal
View GitHub Profile
@Ozzy182
Ozzy182 / show_image _in_taxonomy_list.php
Last active March 14, 2024 09:04
// Add a custom column to product category admin page
<?php
// Add a custom column to product category admin page
function custom_product_category_image_column($columns) {
$columns['category_image'] = 'Image';
$columns['category_color'] = 'Color';
return $columns;
}
add_filter('manage_edit-product_category_columns', 'custom_product_category_image_column');
// Display the ACF image in the custom column
<div class="movie">
<div class="movie__video">
<div class="movie__video__item">
<!-- !!! READ IMPORTANT !!! -->
<!-- Replace the id of the video only.. -> ../embed/ID" -->
<iframe class="youtube-video" width="560" height="315" src="https://www.youtube.com/embed/6FEsFvZ-hqY?enablejsapi=1&version=3&playerapiid=ytplayer&controls=0" modestbranding="0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="movie__video__btn">
<a href="#" class="btn btn-video">play movie</a>
</div>
@Ozzy182
Ozzy182 / pagetype.php
Created October 14, 2023 06:10
Returns the page type : parent, child or normal
<?php
/**
* Page type
* Returns the page type : parent, child or normal
* parent -> have child pages
* child -> have parent pages
* normal -> have no parent and no child
*/
function get_tkef_page_type(){
@Ozzy182
Ozzy182 / Link-master.php
Last active October 6, 2023 04:45
Get all directories and link in the server
@Ozzy182
Ozzy182 / display.php
Created August 16, 2023 10:40
WP CRONJOB
<?php
// $reversePosts = array_reverse($hashtagTopMedia["data"]);
$instaData = get_option('insta_json_data');
if($instaData){
$reversePosts = json_decode($instaData, true);
foreach( $reversePosts as $k=>$h ) {
if($h['media_type'] == "CAROUSEL_ALBUM"){
foreach( $h["children"]["data"] as $key => $media ) {
if ( $h["children"]["data"][$key]["media_type"] === 'IMAGE' ) {
$img_url = $h["children"]["data"][$key]["media_url"];
@Ozzy182
Ozzy182 / ajaxpagination.php
Last active April 3, 2023 05:41
Wp-pagination
<?php
function ajax_pagination($news, $paged, $count){
if($news->found_posts > $count) {
/** Stop execution if there's only 1 page */
if( $news->max_num_pages <= 1 )
return;
// $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $news->max_num_pages );
@Ozzy182
Ozzy182 / wysiwyg.php
Last active January 7, 2023 15:34
Set ACF WYSIWYG Height
<?php
// Remove ACF inline styles for WYSIWYG
function my_acf_input_admin_footer() {
if( get_post_type() == "jobs" ) { ?>
<script type="text/javascript">
(function($) {
acf.add_action('wysiwyg_tinymce_init', function( ed, id, mceInit, $field ){
$(".acf-field .acf-editor-wrap iframe").removeAttr("style");
});
})(jQuery);
@Ozzy182
Ozzy182 / functions.php
Last active December 15, 2022 09:44
Automatic versioning scripts in wordpress
<?php
// Linking CSS and Javascripts required for pages
function project_script_enqueue() {
wp_enqueue_style( 'project-google-fonts', 'https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Noto+Sans+JP:wght@400;500;700&display=swap',array(), null );
wp_enqueue_style('main_style', get_stylesheet_directory_uri() . '/assets/css/app.css',array(), filemtime( get_stylesheet_directory() . '/assets/css/app.css'));
wp_enqueue_style('support_wp_style', get_stylesheet_directory_uri() . '/style.css',array(), filemtime( get_stylesheet_directory() . '/style.css'));
wp_register_script( 'ajax-product', get_stylesheet_directory_uri() . '/assets/js/ajax-product.js', array( 'jquery' ), filemtime( get_stylesheet_directory() . '/assets/js/ajax-product.js'), true );
wp_localize_script( 'ajax-product', 'ajax_product_params', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
wp_enqueue_script( 'ajax-product' );
@Ozzy182
Ozzy182 / Breadcrumb.php
Last active April 19, 2023 09:11
WP Breadcrumb
<?php
/*=============================================
= BREADCRUMBS =
=============================================*/
// Wordpress Breadcrumb Function
// Add this code into your theme function file.
function ah_breadcrumb() {
@Ozzy182
Ozzy182 / menudepth.php
Created June 5, 2022 09:20
Custom acf location for menu depth
<?php
/**
* Custom acf location for menu depth
*/
function acf_location_rules_types($choices)
{
$choices['Menu']['menu_level'] = 'Menu Depth';
return $choices;
}