Articles of functions

How to add author's posts link (HTML + PHP) inside a function to output it

I have this function on a theme which is a bit of code for a slider: function get_article_slide( $title, $excerpt, $link_article, $url_image, $title_length, $alt_image = ‘Alternative text’ ) { // Parameters if ( strlen( $title ) > $title_length ) $title = mb_substr( $title, 0, $title_length ) . “…”; $title = apply_filters( ‘prlx_slide_title’, $title, get_the_title() ); […]

How do I register a new settings page?

I need to be able to create a new settings page, one that will act as a list of information for the user. However, I am unable to find how to do this, can someone point me in the right direction for this? Either to some information or to a question here with the answer.

Hook for altering the content of all wp mails

Hi i want to set email template for all mails for my site . I know how to set up mail template and i set mail template for each of my mail by editing the code ie wp_mail( $recipient, $subject, $body, $headers, $attachments ); is mail code then i replaced it with ob_start(); require_once (get_template_directory() […]

White screen error for a custom theme

I have created a theme for one of our clients using bootstrap framework! When i was working on it on Localhost it works Correctly, but when I Uploaded it doesn’t work. When I Activate it from Appearance I Saw A blank white Page; Also when I Try to Post a new Comment, post, page or […]

Where do I store custom functions that call custom page template files?

I’ve created a WordPress Page template called head.php I then went into /wp-includes/general-template.php and by replicating the default get_header() function that is already there I added this new custom function underneath : function get_head( $name = null ) { do_action( ‘get_head’, $name ); $templates = array(); $name = (string) $name; if ( ” !== $name […]

Removing parent theme CSS without editing parent theme

I am currently developing a child theme that builds on twentyfifteen as a parent theme. However a potential issue has cropped up that is causing a problem. I want to strip the CSS and JS assets from the parent theme twentyfifteen, but these are loaded from the theme’s functions.php file with wp_enqueue_style and wp_enqueue_script, I […]

How to set default archive image without overriding first attached image?

I have hit a wall. I have archive pages with some posts that have featured images which display fine. Some posts don’t have featured images but the first attached image displays. Some posts have no images and there is a blank space. I have been trying all day to find a way to display a […]

Display random text from a file with the WP built-in AJAX API

I want to use a solution by @toscho to display and rotate some quotes. The unchanged code works very well, but if I replace the protected function get_rand() { return rand( 1, 1000 ); } with (from here) protected function get_rand() { $array = file(“wp-content/plugins/quotes-rotator/quotes.txt”); $r = rand(0,count($array)-1); return $array[rand(0,count($array)-1)]; } the code works well […]

What is the correct way to include my new functions and scripts in WordPress?

To include new functions we can write them in the theme’s functions.php. But I have to write my own functions in a new file rather altering the theme’s function.php. I can write any custom js action in footer.php, but I need to write it in other file. How can I do this? Is there any […]

Include Jquery libraries in wordpress theme?

I have a file in my theme’s JS folder named cycle2.js. How do I include the Jquery from ‘wordpress→includes’ into my theme? How do I load this custom JavaScript file ‘cycle2.js’ into my theme? I have: function watercolor_js_scripts(){ if (!is_admin()) { wp_register_script(‘cycle2’, get_template_directory_uri() . ‘/js/cycle2.js’, ‘jquery’, TRUE); wp_enqueue_script( ‘jquery’ ); wp_enqueue_script( ‘cycle2’ ); } add_action(‘init’, […]