If you’re trying to change the styles of the wysiwyg editor, which I assume you are based on your code example, you need to use the add_editor_style()
function.
As per the example in the code reference.
Step 1
Add the following to the functions.php file of your theme.
/**
* Registers an editor stylesheet for the theme.
*/
function wpdocs_theme_add_editor_styles() {
add_editor_style( 'custom-editor-style.css' );
}
add_action( 'admin_init', 'wpdocs_theme_add_editor_styles' );
NB The stylesheet is relative to theme root.
Step 2
Next, create a file named custom-editor-style.css in your themes root
directory. Any CSS rules added to that file will be reflected within
the TinyMCE visual editor. The contents of the file might look like
this:
#tinymce p {
margin: auto;
}
For other p
tags you could try placing some inline style to the admin_head
. Like so,
// Add inline CSS in the admin head with the style tag
// put this in to your theme's functions.php
function my_custom_admin_head() {
echo '<style>p {margin: auto;}</style>';
}
add_action( 'admin_head', 'my_custom_admin_head' );
NB Also make sure the css selectors are correct. I didn’t check them for these examples.