Custom styles in Tiny MCE with an external CSS file

The path to the CSS file tinymce.min.css was incorrect. The solution was to change: $url .= trailingslashit( plugin_dir_url(get_stylesheet_directory_uri()) ) . ‘/tinymce.min.css’; to: $StyleUrl = get_stylesheet_directory_uri().’/style-sheets/tinymce.min.css’; I also had to change: $StyleUrl = plugin_dir_url(get_stylesheet_directory_uri()).’tinymce.min.css’; to: $StyleUrl = get_stylesheet_directory_uri().’/style-sheets/tinymce.min.css’; Now all I had to do was to remove the styles array so the complete code is: // … Read more

WP Customizer API loaded into functions.php

Yes. You can load the code in the customize_register action. One example: <?php // File: functions.php add_action( ‘customize_register’, function( $wp_customize ) { require_once dirname( __FILE__ ) . ‘/inc/customize.php’; wpse256532_customize_register( $wp_customize ); } ); And the inc/customize.php file: <?php // File: customize.php function wpse256532_customize_register( $wp_customize ) { $wp_customize->add_setting( /* … */ ); $wp_customize->add_control( /* … */ … Read more

How do I fit WP_Query arguments into a function?

This should work: $query->set( ‘date_query’, array( ‘relation’ => ‘OR’, array( ‘column’ => ‘post_date’, ‘after’ => ‘-7 days’ ), array( ‘column’ => ‘post_modified’, ‘after’ => ‘-7 days’ ) ) ); You might want to adjust the callback’s name, since it’s not only ordering the home page. You also have _asc in that name but are setting … Read more

Related Posts function not working

The ultimate answer will be in your server logs, I’m afraid. (You can also turn on debugging in wp-config – sometimes that helps too) But I did notice a few things that hopefully can help you track the issue: <?php // You should not require the $orig_post variable… global $post; // Get the tag ids … Read more

Add code to a specific post’s content

Your code is fine, but your logic isn’t working because of $cat. $cat is returning an Array with an Object which you’re trying to check against. But you can easily just use in_category(‘music’) like this: function add_go_back_btn($content) { global $post; $cat = get_the_category(); $post_type = get_post_type(); if(in_category(‘music’) && $post_type === ‘post’) { return ‘<div><a href=”https://wordpress.stackexchange.com/music”>This … Read more

Add Link to Users List (Backend) to open each users front-end profile

The following will add a “View author profile” link to the row actions (i.e., the links that appear when you hover over the username): add_filter (‘user_row_actions’, ‘add_view_author_page’, 10, 2) ; function add_view_author_page ($actions, $user) { $href = esc_attr (get_author_posts_url ($user->ID)) ; $actions[‘add_view_author_page’] = “<a href=”https://wordpress.stackexchange.com/questions/259665/$href”>View author page</a>” ; return ($actions) ; } Edit: Or if … Read more

WordPress function to add text warning on every pages [closed]

Where do you want it to appear? this function will put something before, or after, the content of each page. function rt_before_after($content) { $beforecontent=”This goes before the content.”; $aftercontent=”And this will come after.”; $fullcontent = $beforecontent . $content . $aftercontent; return $fullcontent; } add_filter(‘the_content’, ‘rt_before_after’); If you want it somewhere in particular let me know … Read more