Skip to content

Instantly share code, notes, and snippets.

@mzdebo
mzdebo / add_post_thumb_column.php
Created July 15, 2021 10:56 — forked from mkwebworker/add_post_thumb_column.php
Add a custom column with post thumbnail to the post overview
/* Add the post thumbnail to admin panel - marcokuemmel.de*/
function my_custom_column_content($column)
{
if ($column == 'featuredimage')
{
global $post;
echo (has_post_thumbnail($post->ID)) ? the_post_thumbnail(array(80,80)) : '<p>kein Bild festgelegt</p>' ;
}
}
// for cpt use manage_{$post_type}_posts_custom_column
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
/**
* Default Category Title
*
* @author Bill Erickson
* @url http://www.billerickson.net/default-category-and-tag-titles
*
* @param string $headline
@mzdebo
mzdebo / wp_auto_thumbnail_functions.php
Created April 28, 2021 12:34 — forked from sosukeinu/wp_auto_thumbnail_functions.php
WP function auto featured image
<?php
/*
* This function will get the first image in this order:
*
* 1) Featured image
* 2) First image attached to post
* 3) First image URL in the content of the post
* 4) YouTube screenshot
* 5) Default images for different categories [SET MANUALLY]
<?php
//hierarchical
//hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 );
//create a custom taxonomy name it topics for your posts
function create_topics_hierarchical_taxonomy() {
@mzdebo
mzdebo / gist:10bbeab85563c9256468ba0339ef2666
Created April 28, 2021 12:30 — forked from Pleiades/gist:b9711273719a401d52f3
Sample WordPress Action and Filter Hooks
Code Samples for Hooks And Filters Class
<?php
/* Filter the title to add a page number if necessary.
------------------------------------------------------------------------------------ */
add_filter( 'wp_title', 'page_numbered_wp_title', 10, 2 );
function page_numbered_wp_title( $title, $sep ) {
@mzdebo
mzdebo / readme.md
Created April 28, 2021 12:29 — forked from LeanSeverino1022/readme.md
[_Just enough wordpress] just enough stuff I need for now #wordpress
////////////////////////////////////////////////////////////////////////////////////
// //
// Add media size column to media library //
// //
////////////////////////////////////////////////////////////////////////////////////
// Add custom column to book list
function wh_column( $cols ) {
$cols["dimensions"] = "Dimensions (h)";
return $cols;
////////////////////////////////////////////////////////////////////////////////////
// //
// Create a post from every image in wordpress media gallery //
// //
////////////////////////////////////////////////////////////////////////////////////
//If you have the image in your media library you can just loop through them and create post via wp_insert_post.
// using wp_insert_post() function
// snippet from the Codex
@mzdebo
mzdebo / ci-star-rating.php
Created February 22, 2021 16:29 — forked from nvourva/ci-star-rating.php
Ratings Plugin
<?php
/*
Plugin Name: CI Comment Rating
Description: Adds a star rating system to WordPress comments
Version: 1.0.0
Author: The CSSIgniter Team
Author URI: https://cssigniter.com/
*/
//Enqueue the plugin's styles.
*/ https://rudrastyh.com/woocommerce/before-and-after-add-to-cart.html */
// Before Add to Cart Button
add_action( 'woocommerce_before_add_to_cart_button', 'misha_before_add_to_cart_btn' );
function misha_before_add_to_cart_btn(){
echo 'Some custom text here';
}
// After Add to Cart Button