Add category slug as class attribute in a link array

Ok guys found the solution myself (5 days later, oof) added below to help someone else in the future… foreach((get_the_category( $related_post->ID )) as $category) { $output .= “<a class=\”$category->slug\” href=\””.get_permalink( $related_post->ID ).”\” title=\”” . $category->cat_name . “\”>” . $category->cat_name . “</a>”; } Basically the old link above looked like this… $output .= “<a href=\””.get_permalink( $related_post->ID … Read more

Custom meta box data not saving after wrapping in class

At first glance it looks like you need to add your save routine to a hook, which in this case would save_post. function __construct() { add_action( ‘add_meta_boxes’, array( $this, ‘create_fields_array’) ); add_action( ‘load-post.php’, array( $this,’setup_boxes’) ); add_action( ‘load-post-new.php’, array( $this, ‘setup_boxes’) ); add_action( ‘admin_enqueue_scripts’, array($this, ‘load_scripts’) ); //don’t forget the save routine add_action( ‘save_post’, array($this, … Read more

CPT archive as home page

Re-name your CPT archive to home.php Then use pre_get_posts to alter the home page query so only CPT’s display function wpsites_home_page_cpt_filter($query) { if ( !is_admin() && $query->is_main_query() && is_home() ) { $query->set(‘post_type’, array( ‘your-cpt’ ) ); } } add_action(‘pre_get_posts’,’wpsites_home_page_cpt_filter’); Replace your-cpt with the name of your custom post type. Note: pre_get_posts won’t work with the … Read more

Change custom post status to draft before today

Do the other post have to be set to draft? Or would just showing today’s post work? If just showing today’s post works you could do something like the following $today = getdate(); $args = array( ‘category_name’ => ‘event’, ‘posts_per_page’ => 5, ‘year’ => $today[“year”], ‘monthnum’ => $today[“mon”], ‘day’ => $today[“mday”] ); query_posts( $args );

remove custom post type ulr

Your issue is related to your use of feed, which is both a reserved keyword, and an existing URL rewrite. e.g. RSS feeds etc: example.com/feed/rss2 You need to change your rewrite rules to use something other than ‘feed’ in your URL. The same goes for any taxonomies or post types that try to call themselves … Read more