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
@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.
<?php
$args = array(
'label' => '', // Text in Label
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post meta where id is the meta_key
'id' => '', // required
'name' => '', //name will set from id if empty
@mzdebo
mzdebo / gist:92c620f9912fc0d29b69259e749f2ed4
Created October 17, 2020 20:50 — forked from shanebp/gist:b73343e9c9a6509d2bbc47de80c881c1
add last_activity timestamp to all BP members
/*
* Paste in your theme functions.php or in bp-custom.php.
* Load the site in a browser
* Remove from your theme functions.php or bp-custom.php.
*/
function buddypress_add_last_activity() {
$members = get_users( 'fields=ID' );
// $members = get_users( 'fields=ID&role=subscriber' );
@mzdebo
mzdebo / register-post-type.php
Created October 2, 2020 14:40 — forked from justintadlock/register-post-type.php
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public