After I creating a custom post type and custom taxonomy, I would like to call the custom taxonomy name in my custom columns, but everything I tried just gave me blank information.
My Code:
function news_custom_type() {
$labels = array (
'name' => 'News',
'singular_name' => 'New',
'menu_name' => 'News',
'name_admin_bar' => 'News',
);
$args = array (
'labels' => $labels,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 26,
'menu_icon' => 'dashicons-welcome-write-blog',
'supports' => array('title', 'editor')
);
register_post_type('news', $args);
register_taxonomy(
'news_categories',
'news',
array(
'labels' => array(
'name' => 'Years',
'add_new_item' => 'Add Year',
'new_item_name' => "New Year"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
'hasArchive' => true,
'show_admin_column' => true,
)
);
}
add_action( 'init', 'news_custom_type');
add_filter( 'manage_news_posts_columns', 'set_news_columns' );
add_action( 'manage_news_posts_custom_column', 'news_custom_column', 10, 2);
function set_news_columns($columns) {
$newColumns = array();
$newColumns['title'] = 'Name';
$newColumns['news_categories'] = 'Year';
//$newColumns['zzz'] = 'zzz';
$newColumns['text'] = 'Text';
$newColumns['date'] = 'Date';
return $newColumns;
}
function news_custom_column($column, $post_id) {
switch ($column) {
case 'text' :
echo get_the_excerpt();
break;
}
}
With this i can get this,
https://i.stack.imgur.com/63eiG.png
https://i.stack.imgur.com/PzTxp.png
How can I call the taxonomy, in my case "years" to show in my admin custom columns?
Thank you in advance.
Kind regards.
You need to add another case for the taxonomy
function news_custom_column($column, $post_id) {
switch ($column) {
case 'text' :
echo get_the_excerpt();
break;
case 'news_categories':
$terms = wp_get_post_terms( $post_id, 'news_categories' );
if ( $terms ) {
foreach ( $terms as $term ) {
if ( ! next( $terms ) ) {
echo $term->name;
} else {
echo $term->name . ', ';
}
}
}
break;
}
}
I have a custom post type and custom taxonomy set up using the code below in functions.php.
The URL writes correctly when clicking through on the archive pages on the front end and when clicking "View Post" in the admin edit screen. But when the post is returned in site search results, the custom taxonomy is literally missing. The URL on search results is http://www.example.com/foo//postname.
Any idea why the custom taxonomy in the URL would work in some situations but not in others?
add_action( 'init', 'create_foo_posttype' );
function create_foo_posttype() {
$tax_labels = array(
'name' => _x( 'Foo Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Foo Category', 'taxonomy singular name' ),
'all_items' => __( 'All Foo Categories' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Foo Category' ),
'update_item' => __( 'Update Foo Category' ),
'add_new_item' => __( 'Add New Foo Category' ),
'new_item_name' => __( 'New Foo Category Name' ),
);
register_taxonomy('foo_categories','foo',array(
'labels' => $tax_labels,
'hierarchical' => true,
'has_archive' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'foo' )
));
register_post_type( 'foo',
array(
'labels' => array(
'name' => __( 'Foo' ),
'singular_name' => __( 'Foo' )
),
'public' => true,
'exclude_from_search' => false,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 100,
'capability_type' => 'post',
'supports' => array( 'title', 'author', 'thumbnail', 'trackbacks', 'revisions' ),
'taxonomies' => array( 'foo_categories' ),
'has_archive' => true,
'rewrite' => array( 'slug' => 'foo/%foo_categories%')
)
);
flush_rewrite_rules();
}
add_action( 'init', 'cust_rewrite_init' );
function cust_rewrite_init() {
$GLOBALS['wp_rewrite']->use_verbose_page_rules = true;
}
add_filter( 'page_rewrite_rules', 'cust_rewrite_collect_page_rewrite_rules' );
function cust_rewrite_collect_page_rewrite_rules( $page_rewrite_rules )
{
$GLOBALS['cust_rewrite_page_rewrite_rules'] = $page_rewrite_rules;
return array();
}
add_filter( 'rewrite_rules_array', 'cust_rewrite_prepend_page_rewrite_rules' );
function cust_rewrite_prepend_page_rewrite_rules( $rewrite_rules )
{
return $GLOBALS['cust_rewrite_page_rewrite_rules'] + $rewrite_rules;
}
I found the problem. It wasn't in the code I posted originally. It was here:
add_filter('post_type_link', 'cust_permalink_structure', 1, 4);
function cust_permalink_structure($post_link, $post, $leavename, $sample)
{
if ( false !== strpos( $post_link, '%foo_categories%' ) ) {
$post_type_term = get_the_terms( $post->ID, 'foo_categories' );
$post_link = str_replace( '%foo_categories%', $post_type_term[0]->slug, $post_link );
}
return $post_link;
}
Using $post_type_term[0]->slug; worked if a post had more than one tax value, but failed when the post had only one (which all of my posts do). To fix it, I used array_pop instead of the other array call and it works fine. The resolved code:
add_filter('post_type_link', 'cust_permalink_structure', 1, 4);
function cust_permalink_structure($post_link, $post, $leavename, $sample)
{
if ( false !== strpos( $post_link, '%foo_categories%' ) ) {
$post_type_term = get_the_terms( $post->ID, 'foo_categories' );
$one_term = array_pop($post_type_term);
$post_link = str_replace( '%foo_categories%', $one_term->slug, $post_link );
}
return $post_link;
}
I added this code weeks ago, but it suddenly stopped working last night, how could that be? It works fine on a local server, but not on a shared host. Local is running PHP 5.5.3 and host was running 5.4, but I put in a request to upgrade that specific subdomain to 5.5 just now in case that was at play.
Working with a child theme. The parent theme creates a custom post type called Portfolio, with the slug for all posts in it as /portfolio-item/. In my child theme, I added two things: 1. A new custom post type called Hidden Pages, and I used a code I found online that removes the slug, so it's just domain.com/page-name. 2. I added more code referring to the Portfolio type, which also removes the slug.
Everything was working perfectly, but all of a sudden, all standard pages 404 (and are hidden on the backend, but not in the database, this is not a database problem!), and the Portfolio posts are magically moved to the blog (regular standard posts). If you comment out the custom_pre_get_posts line (132), the problem resolves. But the client needs the urls to be clean without the slug. So I do not want to leave it as-is.
Here is the functions.php for the child theme:
<?php
function evol_child_scripts() {
wp_enqueue_style( 'style', get_stylesheet_directory_uri() . '/stylesheets/css/style.css' );
}
add_action( 'wp_enqueue_scripts', 'evol_child_scripts' );
/*function codex_custom_init() {
$args = array(
'public' => true,
'label' => 'Hidden Pages'
);
register_post_type( 'hidden', $args );
}
add_action( 'init', 'codex_custom_init' );
*/
/**
* Register a custom post type but don't do anything fancy
*/
register_post_type( 'hidden', array( 'label' => 'Hidden Pages', 'public' => true, 'capability_type' => 'post', 'show_ui' => true, 'query_var' => true, 'supports' => array( 'title', 'editor', 'thumbnail' ) ) );
/**
* Remove the slug from published post permalinks. Only affect our CPT though.
*/
function vipx_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( ! in_array( $post->post_type, array( 'hidden' ) )
|| 'publish' != $post->post_status )
return $post_link;
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'vipx_remove_cpt_slug', 10, 3 );
/**
* Some hackery to have WordPress match postname to any of our public
* post types. All of our public post types can have /post-name/ as
* the slug, so they better be unique across all posts. Typically core
* only accounts for posts and pages where the slug is /post-name/
*/
function vipx_parse_request_tricksy( $query ) {
// Only noop the main query
if ( ! $query->is_main_query() )
return;
// Only noop our very specific rewrite rule match
if ( 2 != count( $query->query )
|| ! isset( $query->query['page'] ) )
return;
// 'name' will be set if post permalinks are just post_name,
// otherwise the page rule will match
if ( ! empty( $query->query['name'] ) )
$query->set( 'post_type', array( 'post', 'hidden', 'page' ) );
}
add_action( 'pre_get_posts', 'vipx_parse_request_tricksy' );
function remove_search_filter () {
remove_filter( 'pre_get_posts', 'tr_search_filter' );
}
add_action( 'init', 'remove_search_filter');
function remove_icons() {
wp_dequeue_style( 'icons' );
}
add_action( 'wp_enqueue_scripts', 'remove_icons' );
function tr_widgets_init_2() {
if ( ot_get_option( 'tr_sidebars' ) ) :
$tr_sidebars = ot_get_option( 'tr_sidebars' );
foreach ( $tr_sidebars as $tr_sidebar ) {
register_sidebar( array(
'id' => $tr_sidebar["id"],
'name' => $tr_sidebar["title"],
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h6 class="widget-title">',
'after_title' => '</h6>',
));
}
endif;
};
add_action( 'widgets_init', 'tr_widgets_init_2' );
add_filter('post_type_link','custom_post_type_link', 10, 3);
function custom_post_type_link($permalink, $post, $leavename) {
$url_components = parse_url($permalink);
$post_path = $url_components['path'];
$post_name = end((explode('/', trim($post_path, '/'))));
if(!empty($post_name)) {
switch($post->post_type) {
case 'portfolio':
$permalink = str_replace($post_path, '/' . $post_name . '/', $permalink);
break;
}
}
return $permalink;
}
function custom_pre_get_posts($query) {
global $wpdb;
if(!$query->is_main_query()) {
return;
}
$post_name = $query->get('name');
$post_type = $wpdb->get_var( $wpdb->prepare( 'SELECT post_type FROM ' . $wpdb->posts . ' WHERE post_name = %s LIMIT 1', $post_name ) );
switch($post_type) {
case 'portfolio':
$query->set('portfolio', $post_name);
$query->set('post_type', $post_type);
$query->is_single = true;
$query->is_page = false;
break;
}
return $query;
}
add_action('pre_get_posts','custom_pre_get_posts');
function fb_add_search_box ( $items, $args ) {
// only on primary menu
if( 'primary' === $args -> theme_location )
$items .= '<li class="menu-item menu-item-search">' . get_search_form( FALSE ) . '</li>';
return $items;
}
add_filter( 'wp_nav_menu_items', 'fb_add_search_box', 10, 2 );
// Callback function to insert 'styleselect' into the $buttons array
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
// Register our callback to the appropriate filter
add_filter('mce_buttons_2', 'my_mce_buttons_2');
// Callback function to filter the MCE settings
function my_mce_before_init_insert_formats( $init_array ) {
// Define the style_formats array
$style_formats = array(
// Each array child is a format with it's own settings
array(
'title' => 'Image Text',
'block' => 'p',
'classes' => 'image-text',
),
array(
'title' => 'Image Text no Overlay',
'block' => 'p',
'classes' => 'image-text-2',
),
array(
'title' => 'w/ gray background',
'inline' => 'span',
'exact' => true,
'classes' => 'gray-background',
),
array(
'title' => 'w/ white background',
'inline' => 'span',
'exact' => true,
'classes' => 'white-background',
),
array(
'title' => 'Image Text no Indent',
'block' => 'p',
'classes' => 'image-text-3',
),
array(
'title' => 'Button',
'inline' => 'a',
'exact' => true,
'classes' => 'button small',
),
array(
'title' => 'Blog Image Caption',
'block' => 'p',
'classes' => 'caption',
),
array(
'title' => 'Signature',
'inline' => 'span',
'exact' => true,
'classes' => 'sign',
),
);
// Insert the array, JSON ENCODED, into 'style_formats'
$init_array['style_formats'] = json_encode( $style_formats );
return $init_array;
}
// Attach callback to 'tiny_mce_before_init'
add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );
This is the parent functions.php:
<?php
/*----------------------------------------------------------------------------*/
/* Sets up theme defaults and registers support for various WordPress features.
/*----------------------------------------------------------------------------*/
function tr_theme_setup() {
load_theme_textdomain( 'themerain', get_template_directory() . '/languages' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
register_nav_menu( 'primary', 'Navigation Menu' );
add_theme_support( 'post-thumbnails' );
add_image_size( 'portfolio', 740, 540, true );
}
add_action( 'after_setup_theme', 'tr_theme_setup' );
/*----------------------------------------------------------------------------*/
/* Sets up the content width value based on the theme's design and stylesheet.
/*----------------------------------------------------------------------------*/
if ( ! isset( $content_width ) ) $content_width = 780;
/*----------------------------------------------------------------------------*/
/* Load Theme Options
/*----------------------------------------------------------------------------*/
add_filter( 'ot_show_pages', '__return_false' );
add_filter( 'ot_show_new_layout', '__return_false' );
add_filter( 'ot_theme_mode', '__return_true' );
load_template( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' );
load_template( trailingslashit( get_template_directory() ) . 'includes/theme-options.php' );
load_template( trailingslashit( get_template_directory() ) . 'includes/meta-boxes.php' );
load_template( trailingslashit( get_template_directory() ) . 'includes/theme-functions.php' );
/*----------------------------------------------------------------------------*/
/* Register Sidebars
/*----------------------------------------------------------------------------*/
function tr_widgets_init() {
register_sidebar( array(
'id' => 'sidebar',
'name' => 'Default Sidebar',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h6 class="widget-title">',
'after_title' => '</h6>',
));
register_sidebar( array(
'id' => 'footer-sidebar',
'name' => 'Footer Sidebar',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h6 class="widget-title">',
'after_title' => '</h6>',
));
if ( ot_get_option( 'tr_sidebars' ) ) :
$tr_sidebars = ot_get_option( 'tr_sidebars' );
foreach ( $tr_sidebars as $tr_sidebar ) {
register_sidebar( array(
'id' => $tr_sidebar["id"],
'name' => $tr_sidebar["title"],
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h6 class="widget-title">',
'after_title' => '</h6>',
));
}
endif;
};
add_action( 'widgets_init', 'tr_widgets_init' );
/*----------------------------------------------------------------------------*/
/* Register and load CSS & jQuery
/*----------------------------------------------------------------------------*/
function tr_enqueue_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_style( 'icons', get_template_directory_uri() . '/assets/css/icons.css' );
wp_enqueue_style( 'magnific', get_template_directory_uri() . '/assets/css/magnific-popup.css' );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'custom', get_template_directory_uri() . '/assets/js/jquery.custom.js', 'jquery' );
wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/assets/js/jquery.flexslider.min.js', 'jquery' );
wp_enqueue_script( 'isotope', get_template_directory_uri() . '/assets/js/jquery.isotope.min.js', 'jquery' );
wp_enqueue_script( 'magnific', get_template_directory_uri() . '/assets/js/jquery.magnific-popup.min.js', 'jquery' );
wp_enqueue_script( 'validation', get_template_directory_uri() . '/assets/js/jquery.validate.min.js', 'jquery' );
if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
}
add_action( 'wp_enqueue_scripts', 'tr_enqueue_scripts' );
/*----------------------------------------------------------------------------*/
/* Load Widgets
/*----------------------------------------------------------------------------*/
include( "includes/widget-recent-projects.php" );
/*----------------------------------------------------------------------------*/
/* Configure Pagination
/*----------------------------------------------------------------------------*/
function tr_pagination() {
global $wp_query, $wp_rewrite;
$pages = '';
$total = 1;
$max = $wp_query->max_num_pages;
if ( ! $current = get_query_var( 'paged' ) ) $current = 1;
$args['base'] = str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) );
$args['total'] = $max;
$args['current'] = $current;
$args['end_size'] = 1;
$args['mid_size'] = 3;
$args['prev_text'] = '<i class="fa-angle-left"></i> Previous';
$args['next_text'] = 'Next <i class="fa-angle-right"></i>';
$args['type'] = 'list';
if ( $max > 1 ) echo '<div id="pagination">';
if ( $total == 1 && $max > 1 );
echo $pages . paginate_links( $args );
if ( $max > 1 ) echo '</div>';
}
/*----------------------------------------------------------------------------*/
/* Configure Excerpt
/*----------------------------------------------------------------------------*/
function new_excerpt_more( $more ) {
return ' ...';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
/*-----------------------------------------------------------------------------------*/
/* Configure Tag Cloud
/*-----------------------------------------------------------------------------------*/
function tag_cloud_filter($args = array()) {
$args['smallest'] = 12;
$args['largest'] = 12;
$args['unit'] = 'px';
return $args;
}
add_filter('widget_tag_cloud_args', 'tag_cloud_filter', 90);
/*----------------------------------------------------------------------------*/
/* Exclude Pages from Search
/*----------------------------------------------------------------------------*/
function tr_search_filter( $filter ) {
if ( $filter->is_search ) {
$filter->set( 'post_type', 'post' );
}
return $filter;
}
add_filter( 'pre_get_posts', 'tr_search_filter' );
/*----------------------------------------------------------------------------*/
/* Add Portfolio Post Types
/*----------------------------------------------------------------------------*/
function tr_portfolio() {
$labels = array(
'name' => 'Portfolio',
'singular_name' => 'Portfolio Item',
'add_new' => 'Add New',
'add_new_item' => 'Add New Portfolio Item',
'edit_item' => 'Edit Portfolio Item',
'new_item' => 'New Portfolio Items',
'view_item' => 'View Portfolio Item',
'search_items' => 'Search Portfolio Items',
'not_found' => 'No Portfolio Items found',
'not_found_in_trash' => 'No Portfolio Items found in Trash',
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 4,
'rewrite' => array( 'slug' => 'portfolio-item' ),
'supports' => array( 'title', 'editor', 'thumbnail' )
);
register_post_type( 'portfolio', $args );
register_taxonomy(
"portfolio-category", array( "portfolio" ), array(
"hierarchical" => true,
"label" => "Portfolio Categories",
"singular_label" => "Portfolio Categories",
"rewrite" => true,
"query_var" => true
)
);
}
add_action( 'init', 'tr_portfolio' );
/*----------------------------------------------------------------------------*/
/* Add Gallery Post Types
/*----------------------------------------------------------------------------*/
function tr_gallery() {
$labels = array(
'name' => 'Gallery',
'singular_name' => 'Gallery Item',
'add_new' => 'Add New',
'add_new_item' => 'Add New Gallery Item',
'edit_item' => 'Edit Gallery Item',
'new_item' => 'New Gallery Items',
'view_item' => 'View Gallery Item',
'search_items' => 'Search Gallery Items',
'not_found' => 'No Gallery Items found',
'not_found_in_trash' => 'No Gallery Items found in Trash',
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 4,
'rewrite' => array( 'slug' => 'gallery-item' ),
'supports' => array( 'title', 'thumbnail' )
);
register_post_type( 'gallery', $args );
register_taxonomy(
"gallery-category", array( "gallery" ), array(
"hierarchical" => true,
"label" => "Gallery Categories",
"singular_label" => "Gallery Categories",
"rewrite" => true,
"query_var" => true
)
);
}
add_action( 'init', 'tr_gallery' );
/*----------------------------------------------------------------------------*/
/* Add a Custom Taxonomy to the Post Class
/*----------------------------------------------------------------------------*/
function custom_portfolio_post_class( $classes, $class, $ID ) {
$taxonomy = 'portfolio-category';
$terms = get_the_terms( (int) $ID, $taxonomy );
if ( ! empty( $terms ) ) {
foreach ( (array) $terms as $order => $term ) {
if ( ! in_array( $term->slug, $classes ) ) {
$classes[] = $term->slug;
}
}
}
return $classes;
}
add_filter( 'post_class', 'custom_portfolio_post_class', 10, 3 );
function custom_gallery_post_class( $classes, $class, $ID ) {
$taxonomy = 'gallery-category';
$terms = get_the_terms( (int) $ID, $taxonomy );
if ( ! empty( $terms ) ) {
foreach ( (array) $terms as $order => $term ) {
if ( ! in_array( $term->slug, $classes ) ) {
$classes[] = $term->slug;
}
}
}
return $classes;
}
add_filter( 'post_class', 'custom_gallery_post_class', 10, 3 );
/*----------------------------------------------------------------------------*/
/* Register the Required Plugins
/*----------------------------------------------------------------------------*/
require_once dirname( __FILE__ ) . '/includes/plugin-activation.php';
function tr_register_required_plugins() {
$plugins = array(
array(
'name' => 'Rain Shortcodes',
'slug' => 'rain-shortcodes',
'source' => get_stylesheet_directory() . '/includes/plugins/rain-shortcodes.zip',
'required' => true,
'version' => '',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => '',
)
);
$theme_text_domain = 'tgmpa';
$config = array(
'domain' => $theme_text_domain,
'default_path' => '',
'parent_menu_slug' => 'themes.php',
'parent_url_slug' => 'themes.php',
'menu' => 'install-required-plugins',
'has_notices' => true,
'is_automatic' => true,
'message' => '',
'strings' => array(
'page_title' => __( 'Install Required Plugins', $theme_text_domain ),
'menu_title' => __( 'Install Plugins', $theme_text_domain ),
'installing' => __( 'Installing Plugin: %s', $theme_text_domain ), // %1$s = plugin name
'oops' => __( 'Something went wrong with the plugin API.', $theme_text_domain ),
'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ),
'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ),
'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ),
'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ),
'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ),
'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ),
'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ),
'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ),
'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins' ),
'return' => __( 'Return to Required Plugins Installer', $theme_text_domain ),
'plugin_activated' => __( 'Plugin activated successfully.', $theme_text_domain ),
'complete' => __( 'All plugins installed and activated successfully. %s', $theme_text_domain ),
'nag_type' => 'updated'
)
);
tgmpa( $plugins, $config );
}
add_action( 'tgmpa_register', 'tr_register_required_plugins' );
?>
When wp_debug is set to true, this returns:
Strict Standards: Only variables should be passed by reference in
[path redacted]/functions.php on line 97
This refers to this line:
$post_name = end(explode('/', trim($post_path, '/')));
This is still in the error log, but after a change, it is not there on the admin side, does that mean it's fixed?
Child theme code is from here: https://gist.github.com/stefanbc/6620151 and http://www.markwarddesign.com/2014/02/remove-custom-post-type-slug-permalink/
So, if anyone knows how to modify this file to revert everything back to working perfectly, that'd be great. We are days away from launch, actually. Eep. Thank you!
Problem is not with Wordpress as the error stated, It's all pure PHP. You should make a little change in that line (wrapping explode() with parenthesis):
$post_name = end((explode('/', trim($post_path, '/'))));
I could not find a solution to this problem given my level of PHP and not wanting to rewrite code that involves both a parent and child theme's functions. I ended up removing all code that attempted to remove the slug. I crossed my fingers and installed this outdated plugin and it worked. So for anyone for future reference, I suppose you can avoid code and just use this instead!
https://wordpress.org/plugins/remove-slug-from-custom-post-type/