echo value from ‘select’ field type into page template using cmb2?

For starters, I recommend you use the API for register metaboxes and fields which can be seen here: https://github.com/WebDevStudios/CMB2/wiki/Basic-Usage#create-a-metabox. To echo the select option’s label, you would do something like this: add_action( ‘cmb2_admin_init’, ‘custom_metabox’ ); function custom_metabox() { $cmb = new_cmb2_box( array( ‘id’ => REALIA_PROPERTY_PREFIX . ‘ficha_tecnica’, ‘title’ => ‘Ficha Técnica’, ‘object_types’ => array( ‘property’ … Read more

ajax category filter

Not sure if you’ve solved this or not but I was looking for a way to embed this within a page and filter posts by category. I got this working so it displays all categories and the posts related. Put that in functions.php function ajax_filter_posts_scripts() { // Enqueue script wp_register_script(‘afp_script’, get_template_directory_uri() . ‘/js/ajax-filter-posts.js’, false, null, … Read more

opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);

I am not sure if there’s a native function for this, but a little regex might help the case: function open_links_in_new_tab($content){ $pattern = ‘/<a(.*?)?href=[\'”]?[\'”]?(.*?)?>/i’; $content = preg_replace_callback($pattern, function($m){ $tpl = array_shift($m); $hrf = isset($m[1]) ? $m[1] : null; if ( preg_match(‘/target=[\'”]?(.*?)[\'”]?/i’, $tpl) ) { return $tpl; } if ( trim($hrf) && 0 === strpos($hrf, ‘#’) … Read more

WP showing “warning: call_user_func_array()”, What to do?

The error you’re getting is showing, because somewhere on your site (your theme or one of your plugins) is registering a filter function that doesn’t exist. Somewhere in your code, there will be such line (or similar to it): add_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); It may use different hook, so it may also look like: add_filter( … Read more

How do I create a new WP admin color scheme?

This code works with WordPress 5.2 and is correct. You now need to go to your Profile and select it by going to Users > Your Profile > Admin Color Scheme select the scheme and save. Edit: Adding updated code for your colors CSS file since you’re using a child theme: function additional_admin_color_schemes() { wp_admin_css_color( … Read more

Enabling Sessions in WordPress 3.0

If you need to manually enable the session globally, use this in your functions.php (I included a line for manually setting a session variable as an example, not required): add_action(‘init’, ‘session_manager’); function session_manager() { if (!session_id()) { session_start(); } $_SESSION[‘foo’] = ‘bar’; } and if you wanted to manually clear the session on an event … Read more

How can I programmatically create “child” pages on theme activation?

As @Soulseekah said, you can do this with post_parent. I didn’t test with the following code, but it should work $pages = array( array( ‘name’ => ‘page1’, ‘title’ => ‘Page 1’, ‘child’ => array( array( ‘name’ => ‘page11’, ‘title’ => ‘Page 1.1’ ), array( ‘name’ => ‘page12’, ‘title’ => ‘Page 1.2’ ) ) ), array( … Read more

How to add the category ID to admin page

The hooks for taxonomies are: “manage_edit-${taxonomy}_columns” for the header “manage_edit-${taxonomy}_sortable_columns” to make columns sortable “manage_${taxonomy}_custom_column” for the cell content To catch all taxonomies write: foreach ( get_taxonomies() as $taxonomy ) { add_action( “manage_edit-${taxonomy}_columns”, ‘t5_add_col’ ); add_filter( “manage_edit-${taxonomy}_sortable_columns”, ‘t5_add_col’ ); add_filter( “manage_${taxonomy}_custom_column”, ‘t5_show_id’, 10, 3 ); } add_action( ‘admin_print_styles-edit-tags.php’, ‘t5_tax_id_style’ ); function t5_add_col( $columns ) { … Read more