How to add new CSS file to new PHP file

CSS links are relative to the current request URI, not your PHP file. Use an absolute path like: <link rel=”stylesheet” href=”https://wordpress.stackexchange.com/questions/184258/<?php bloginfo(“template_url’ ) ?>/themesubfolder/style.css” />

Trying to run website a php file is blank

That’s normal and expected inside the wp-content, themes, and plugins directories. Their presence is to prevent listing of directory contents if people navigate to those directories via http. There’s nothing wrong there and no fix is required.

Adding “redirect” to a button

You will need to use a hook (such as init or admin_init) to detect whether a condition has been met. For instance, the existence of a certain querystring variable (which can be a url encoded url, if you like). When the condition is met, use wp_safe_redirect() (and optionally exit()) to redirect to the URL you … Read more

Add categorys to custom post type not working

That is not the way to register a Taxonomy.Please find the code below to register a Taxonomy for a custom post type :- $args = array( “label” => “Butik Categories”, “singular_label” => “Butik Category”, ‘public’ => true, ‘hierarchical’ => true, ‘show_ui’ => true, ‘show_in_nav_menus’ => false, ‘args’ => array( ‘orderby’ => ‘term_order’ ), ‘rewrite’ => … Read more

Genesis / custom template page / setting the page title and meta desc

Yoast Support kindly provided me with the following reference: https://yoast.com/wordpress/plugins/seo/api/ Using the following filters calling my own functions, I was able to change everything in the header based on dynamic content. add_filter(‘wpseo_title’, ‘setPageTitle’, 10); add_filter(‘wpseo_metadesc’, ‘setMetaDesc’, 10); add_filter(‘wpseo_canonical’, ‘setCanonical’, 10); add_filter(‘wpseo_opengraph_image’, ‘setOG_Image’, 10); add_filter(‘the_title’, ‘setTitle’, 10);

Cannot load media and I get “PHP Warning: Invalid argument supplied for foreach(“

@TheDeadMedic was right, in my second code snippet, admin_init should be admin_menu. That solved my problem, thanks a lot to all of you! Corrected code: //remove from menu function remove_posts_menu() { remove_menu_page(‘edit.php’); remove_menu_page(‘edit.php?post_type=page’); remove_menu_page(‘edit-comments.php’ ); } add_action(‘admin_menu’, ‘remove_posts_menu’);

Angular not defined [closed]

You should use wp_enqueue_script to add the script. The documentation contains information about the function and how it should be used and some helpful examples. Basically, you will need to add something like this to the functions.php file: function myextension_enqueue_scripts() { wp_enqueue_script( ‘myextension-angular’, plugins_url( ‘/assets/js/angular.min.js’ , __FILE__ ), // If you are working on a … Read more

Post class only applying to first excerpt; why?

Try this way <table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″ align=”center”> <tr> <td width=”100%” valign=”top”> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> <h2><a href=”https://wordpress.stackexchange.com/questions/188003/<?php the_permalink() ?>”><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> <p><?php the_time(‘F j, Y’); ?> at <?php the_time(‘g:i a’); ?> | <?php the_category(‘, … Read more

How to organize functions.php content

As @Tom J Nowell says, don’t nest functions. Just write them normally: function my_theme_prefix_setup() { // Add theme support etc. } add_action( ‘after_setup_theme’, ‘my_theme_prefix_setup’ ); function my_theme_prefix_init() { // Register a post type } add_action( ‘init’, ‘my_theme_prefix_init’ ); Or using a class: class my_theme { function __construct() { add_action( ‘after_setup_theme’, array( $this, ‘setup’ ) ); … Read more

Why my query does not run with prepare

That is not how $wpdb->prepare works. You feed prepare a string with sprintf-like placeholders, and the appropriate replacement values. Placeholders The query parameter for prepare accepts sprintf()-like placeholders. The %s (string), %d (integer) and %f (float) formats are supported. (The %s and %d placeholders have been available since the function was added to core in … Read more