How to style options page in dashboard?

You can simply add those CSS to admin HEAD section, it’s fast and easy solution. function jrl_styles() { ?><style type=”text/css”> #jrl-wrap { width: 700px; padding: 3em; /* … */ } </style><?php } add_action(‘admin_head’, ‘jrl_styles’); Or you can enque your CSS file like this: function load_custom_wp_admin_style() { wp_register_style( ‘custom_wp_admin_css’, get_stylesheet_directory_uri() . ‘/functions/site-options.css’, false, ‘1.0.0’ ); wp_enqueue_style( … Read more

Is_template how to add one more template [closed]

Here’s an example using the default WordPress is_page_template function: <?php if ( is_page_template( ‘base-gallery-rail.php’ ) ) { wp_enqueue_style(‘ztheme-gallery-style’); } else if ( is_page_template( ‘other-template.php’ ) ) { wp_enqueue_style(‘other-style’); } else { // the last else is only required if you want to have a default wp_enqueue_style(‘default’); } You can add as many else if ( … Read more

How to output a PHP file values by shortcode?

We’ve built shortcodes in the past using concatenating variables. To paraphrase the link above, you should output your PHP as such. $output=”<p>”; $output .= ‘<strong>’ . $content . ‘</strong>’; $output .= ‘</p>’; return $output; Note, see the .= variable concatenation.

Using WordPress gettext functions in a library outside plugin or theme scope

WordPress doesn’t quite have a practice of localizing something that isn’t core/plugin/theme. My educated guess would be that it will work just fine with same concepts, but you will have to write custom loading logic. Use lower level load_textdomain(), since higher level functions are meant for plugins/themes specifically. As long as you determine and load … Read more

Using fwrite() and “a” appends multiple times instead of once

You could try putting your code in a WordPress Action or Filter call: add_action( ‘init’, ‘my_file_function’ ); function my_file_function() { $content = “some text here\n”; $fp = fopen($_SERVER[‘DOCUMENT_ROOT’] . “/wp-content/themes/zerif-lite-child/myText.txt”,”a”); fwrite($fp,$content); fclose($fp); } The flag (‘a’ vs ‘wb’) doesn’t have anything to do with your problem, it just happens to showcase it. For whatever reason, … Read more

WordPress blog post url on category page

You don’t have a $post object to use $post->ID, so use get_the_ID() instead. In your loop: <?php $ptype_link_url = get_post_meta(get_the_ID(), ‘lolfmkbox_link_url’, true); ?> <h1 class=”entry-title”><a href=”https://wordpress.stackexchange.com/questions/209732/<?php echo $ptype_link_url; ?>”><?php the_title(); ?></a></h1> Reference: https://codex.wordpress.org/Function_Reference/get_the_ID