A function is a sequence of program instructions that perform a specific task. It is packaged as a unit that can be used wherever the according task should be performed.

learn more… | top users | synonyms (2)

0
votes
1answer
1k views

Session is not starting

I've read the usage of session() in WordPress from here and here. And I placed the following code into the very starting of my functions.php: /** * ENABLING SESSION TO THE SITE * Thanks: Shazzad ...
-1
votes
1answer
70 views

Make a PHP file with a function

I want to use the breadcrumb function as listed here: https://gist.github.com/melissacabral/4032941 Putting the code in functions.php works for me, but I would rather have it in a separate PHP file. ...
2
votes
1answer
2k views

Remove wp-mediaelement.css from wp_head

I´m customizing the new core audio/video player via CSS in my styles.css. I tried to remove the wp-mediaelement.css with the following code in functions.php, because I don´t need it anymore. function ...
1
vote
1answer
33 views

Add tag parameter to category.php

I want to give users the ability to refine their results in the category section. Like if the user is in the "car" category section in there he can then refine the "search" by color, number of wheels, ...
0
votes
0answers
25 views

How to get new posts via Ajax when using Waypoint.js

So I have an ajax call in one of my pages when you hit a certain waypoint within the dom. I then call a Wordpress function that I have created. The function is working in that it gets the first posts, ...
2
votes
1answer
110 views

Gallery images titles - get from post

Is there any possibility to make a functions hook, which will automatically override titles of added images (or added during gallery creation) with post title? Just like in the example: - im creating ...
6
votes
4answers
9k views

Get the blog page URL set in Options

I have set the blog to be a different page other than the home page. I want to have a link from single.php to this blog page. Is there any function that pulls out URL for the blog ?
9
votes
1answer
105 views

When should you, and when should you not, use wp_list_pluck()?

While learning about metadata lazy-loading, I met these lines of code: // Don't use `wp_list_pluck()` to avoid by-reference manipulation. $comment_ids = array(); if ( is_array( $comments ) ) { ...
2
votes
1answer
1k views

Scheduling posts to update once per day with wp_cron

I have a function that hooks into save_post that changes the value of a custom taxonomy term based on today's date. That's working fine. When I update a post, the taxonomy term is updated correctly. ...
2
votes
1answer
46 views

add_filter priority problem

I'm using basic user avatars for use local avatar in wordpress. And i have a simple function in my functions.php for getting avatar direct link. My problem is if i use get_avatar function in my ...
0
votes
1answer
65 views

Merging two excerpt functions to work with conditions

I have two functions that affect the_excerpt: // Grab First Paragraph Of Text And Ignore Images For Excerpt function awesome_excerpt($text, $raw_excerpt) { if( ! $raw_excerpt ) { ...
0
votes
1answer
13 views

Newest comments first not working

I'd like to have my newest comments listed first but nothing seems to be working. In the dashboard I set In comments.php I have <?php wp_list_comments(array( 'reverse_top_level' => true, ...
5
votes
3answers
381 views

Create “File-less” Page Template in Functions.php

(By "Page Template," I mean a theme file with the "Template Name" header that can be selected in the "Template" dropdown field on the page admin.) In multiple instances, I've built page templates ...
0
votes
1answer
37 views

Add custom field to attachments in a specific category

I have a working function that adds a meta field to all attachments (so I can enter the url of a video). I would like this field to populate only on attachments in the "video" category. I've tried ...
1
vote
1answer
26 views

Setting youtube size in functions.php

I'm using the code below to set the width and height of youtube embeded links ////////////////////////////////////////////////////////////////// // Youtube shortcode //////////////////////////////////...
1
vote
0answers
52 views

Wordpress not cropping thumbnails properly

For some reason Wordpress is ignoring my thumbnail sizes and keeping thumbnails cropped proportionately instead of specific dimensions. Here is what I have in my functions.php: add_image_size('main-...
0
votes
0answers
12 views

Gallery Meta box not showing on single post

I want t replicate a Tour module into restaurant, not much gud in development so have created a Custom Post Type "Restaurant". It has same features as "tour" have but i get stuck when a Gallery meta ...
5
votes
1answer
36 views

Customizing subject in comment notification e-mails

How do you customize the following code in functions.php in order to have "New comment" as subject in comment notification e-mails instead of the default WordPress subject? function ...
0
votes
1answer
24 views

How to store a number (coming from cookie) into query vars for later usage in other filters?

I have a small HTML5 game playable (as "canvas") at different social networks, which sets an HTTP cookie. When a player comes to my Wordpress site (acting as help and support website for the game), I ...
0
votes
0answers
9 views

Add a “NEW” banner to bottom of every new post [duplicate]

I'm working on http://juniorgoldreport.com The owner wanted a "new" banner tag on new post's, so to make it easy I was going to put it on the images, but because of scaling and different images it's ...
0
votes
1answer
66 views

Get Attachment Category Name

How can I call the name of an attachment category? Something that would look like <?php get_attachment_category_name ?> or $attachment->category_name This would simply output the name of ...
2
votes
1answer
49 views

A snippet after every image

folks. I need to put a piece of code after every post image (post attached image). it's something like this: <img class="alignnone size-full wp-image-3079" src="imgurl.jpg" alt="02" width="2592" ...
1
vote
1answer
52 views

wp_register_script(… $in_footer = true) not working

I'd like to load some javascript files in my footer. I tried to accomplish it in functions.php like so: function my_init() { // LOAD JQUERY wp_deregister_script('jquery'); ...
3
votes
1answer
31 views

Including a function into a theme

I have a small function, that I have been using for many years, to clean up user entered text on website forms that prepares the input for use in MySQL queries and also removes all the input from ...
1
vote
1answer
42 views

Automatically include all php files in a child theme directory

I'm currently using a custom child theme across multiple sites, and would like to modularise particular custom features (e.g. ecommerce) by separating them into individual php files, and including the ...
3
votes
1answer
22 views

What function to hook for changes made in status and visibility of a post

I have a function to run every time a post is published or updated in anyway. Right now I am doing function myFunction(){ //Do Something } add_filter('publish_post','myFunction'); add_filter('...
1
vote
1answer
41 views

Trying to establish connection to External Database

I'm trying to get a connection to a separate external database from the database the wordpress site depends on. I have a PHP file inside the same location of my theme, it is basically a blank PHP it ...
0
votes
3answers
98 views

Add URL parameter to all internal links using a specific theme

I got stuck with some modifications and maybe someone could give me some help. What am I doing I use the multiple theme plugin to switch themes for my WordPress project. To switch between the ...
3
votes
1answer
27 views

I changed “Howdy” in the admin bar in the dashboard, but when I'm viewing the site it still says Howdy!

I used the following code to replace "Howdy" in the admin bar. This is lovely. However, when I view the site while logged in, the word Howdy reappears. As long as I'm viewing the dashboard, no howdy. ...
0
votes
1answer
3k views

Echo a div to header.php from functions.php

Within the section of header.php I have a div structure <div id="header"> <div id="masthead"> <div id="branding"> ... I want to add a div within "branding" - I can do this ...
0
votes
0answers
45 views

Block user redirection to wp-login.php on leaving password blank in frontend login

When a user leaves the Username / Password / Both Blank and clicks login in frontend buddypress login, he is being redirected to wordpress admin login url stating wrong username/password/empty ...
0
votes
1answer
28 views

Pass arguments to function class with do_action()

I'm trying to develop a "simple" script where i can create a filename with a timestamp of the last edit. For this I'm trying to code a class – but I'm having problems to pass an argument to add_action....
0
votes
1answer
79 views

WordPress SEO By Yoast Plugin is interfering with a custom function code - how to troubleshoot and fix it?

I'm trying to optimize my page load on my WP site. I've copied a custom function (can't remember where I pulled it from) to optimize my pages. Things that it can are the following: move javascript ...
1
vote
1answer
26 views

Echo tags used to describe the theme

I've got a plugin I am working on to return an instance of the WP_Theme object properties. The plugin essentially allows for a simple child-theme creation. /* Theme Name: <?php echo $...
2
votes
2answers
3k views

get_current_site() not returning site name

The function get_current_site() that's in my themes' footer.php file doesn't return the 'site name' property as specified in the docs (and expected in the theme). The purpose of the function is to ...
-2
votes
1answer
29 views

Trying to Add a LEFT Sidebar?

I'm running the base 2016 wordpress theme. I have modified it to allow for a left side sidebar. I am able to see the admin side of the sidebar like so: I have registered the call in the functions....
0
votes
0answers
23 views

Auto expire page that contains specific text

Sorry, I'm relatively new to Wordpress. Is there a function or script that can automatically expire a page that contains specific text? I am using an RSS feed to display some content on a page (not ...
0
votes
1answer
337 views

WooCommerce - Customer Order History Pagination

I'm trying to implement pagination into WC's customer order history that can be seen on the "My Account" page using woo_pagination(). https://docs.woothemes.com/document/woo_pagination/ The template ...
0
votes
0answers
18 views

How to a override parent theme page that has been included with require_once?

I need to override a parent theme file which is added in function.php like this: if (class_exists('Woocommerce')) { require_once( get_template_directory() . '/woocommerce/config.php'); } A template ...
0
votes
0answers
16 views

auto metakey value on post tile

I have this metakey "word_srch" the metakey has no value, i have to input the value in the custom field in the backed, instead, how can i create a function code that will automatically input the value ...
0
votes
1answer
35 views

wp_redirect only works on main site and not on other sites

My main site is https://www.domain.com/, all my multisites will have https://www.domein.com/multisite1/ link. I made a function in functions.php which will check if the option (in the admin panel) is ...
-1
votes
1answer
40 views

Using a filter in functions.php to add content to single posts regardless if post is in main or child category

Im using following filter (codex) to add some html content with a lower priority (20) to the bottom of my single posts wich are in a specified category: add_filter( 'the_content', '...
0
votes
0answers
16 views

Transfer custom post nav (prev/next) from one to another theme

I bought two themes and just want to assume a special next/prev post navigation from the first theme in the second theme. I've searched the theme files and found the function, which declares this ...
3
votes
3answers
57 views

Is the Wordpress HTTPS Plugin Still Safe To Use? [closed]

I have a client who wants to accept Authorize.net donations on their website. We only have a need for one page to be secured for our purposes. I've put a lot of research into this and it seems that ...
1
vote
1answer
28 views

Set spesific size of featured images

I am trying to reduce the loading speed of my webpage. Google PageSpeed Insights tells me to optimize my images. In the following code, how can I set an image size so that if the uploaded image is ...
2
votes
0answers
23 views

Date/time limitation of posts where function must be executed

I have this piece of function in my functions.php file: function user_content_replace($content) { $sentences_per_paragraph = 3; // settings $pattern = '~(?<=[.?!…])\s+~'; // some punctuation and ...
-2
votes
1answer
26 views

Getting error on function.php

<?php define('TEMPPATH',get_bloginfo('stylesheet_directory')); define('IMAGES',TEMPPATH."/images"); add_theme_support('nav_menus'); if(function_exists('register_nav_menus')) { ...
2
votes
1answer
39 views

Theme-Config tab in admin Pannel?

Sorry, for my broke english. There are few questions that I'd want to ask that got me quite confuse. I will try to phrase and describe my question the best way I could. Starting with a bit of ...
2
votes
0answers
49 views

Download external images with function

Actually, i display images on my site from other sites. Url is on a custom field name "couv" I'd like to download theses pictures on my site and create a new custom field with the new value "couv2" I ...
26
votes
8answers
64k views

How to include PHP files in plugins the correct way

My problem is when on the main plugin file I include a PHP file something like this: include(WP_PLUGIN_URL . '/wordpress-group-buying/ipn/paypal-ipn.php'); // or include_once(WP_PLUGIN_URL . '/...