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
0answers
6 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 ...
0
votes
1answer
22 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 ...
0
votes
2answers
580 views

Custom registration form in shortcode getting internal server error 500 [on hold]

I created a custom registration form which works fine when used as a custom page template. I needed it as a shortcode so I created a shortcode using the function below /* Custom shortcode */ function ...
2
votes
2answers
880 views

Using plugin functionality in external php script not working

I am encountering a strange problem which I couldn't solve so far. I'm calling a .php script via cronjob (Debian/GNU Linux). To use wordpress functionailty I added: define('WP_USE_THEMES', false); ...
0
votes
1answer
8 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'); ...
0
votes
1answer
19 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
1answer
19 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 ...
3
votes
1answer
896 views

Remote upload file to server B

I'm aware this might be some of the hardest coding to do ever, but thought of giving it a try. Im basically trying to detect all (mp3) filetypes uploaded through the Wordpress media upload and send ...
3
votes
2answers
7k views

Using wp_get_nav_menu_items() to list children of children pages

I'm working with a Genesis Based Theme and I'd like build a Page/ Child Page menu structure. That part I can do with the help of some code produced by Bill Erickson. Essentially what I'm trying to do ...
0
votes
2answers
492 views

Passing variable as add_shortcode argument

I'm trying to pass a variable into the add_shortcode function to be used as the shortcode name but it does not seem to be working. Is there a way that I can pass a variable similar to this? foreach ...
0
votes
3answers
57 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 ...
0
votes
0answers
28 views

Action Hook before Product Subtotal in Woocommerce Cart and Checkout [on hold]

I try to insert (hook) a custom row just before the first subtotal row in the cart page and checkout page with a function in my functions.php. I checked the official Woocommerce Hook Reference Site - ...
1
vote
1answer
17 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
781 views

Load post attached images on a single page site with fancybox

I'm trying to make a single page site that will display posts as thumbnails in some part. Then if a thumbnail is clicked, I want all the images contained in this post to be loaded with fancybox while ...
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
1answer
889 views

Remove Header and Footer in iframe

Many people embed my website's pages in their websites as iframes. I want them to don't take my footer, header and a specific division in those iframes. Since, footer, header and mentioned specific ...
0
votes
0answers
28 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
23 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 ...
0
votes
1answer
75 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
20 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 ...
0
votes
1answer
530 views

Change custom post type slug from plugin options

I'd like to give users the option to change a custom post type slug in my plugin. Using this answer, I'm able to hardcode it into a function: Redeclare/Change Slug of a Plugin's Custom Post Type ...
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 ...
0
votes
1answer
2k views

Let users upload image(s) to the post from front end

I want to enable logged in users (Wordpress) to submit posts from front end (among with other data). My form is working great, I add custom post meta data which I later display on custom post page. ...
-4
votes
1answer
20 views

Wordpress adding style display none to body tag [closed]

I have been searching for a solution to this issue, but somehow, I am unable to come up with any results with the same issue, either here or other sites. I have turned my pure html and .less site ...
0
votes
0answers
3 views

Comparing a number to each value in array [migrated]

I have users submit tempos(number) and I would like to compare that number to an array of preset numbers and return one value that is the next number up from it. For example: Submitted tempo - ...
0
votes
2answers
652 views

Show the post date using the wp_get_archives() function?

I have some doubt about the wp_get_archives() function In my website I have create the following page template that use the wp_get_archives() function to show the posts list: <?php /** ...
1
vote
2answers
647 views

Update user meta of author when post content is viewed

I have a value that I'm trying to store as user meta for authors on my site. I need it to update itself every time the content of a post is viewed for that author. Here's as far as I've gotten but it ...
-2
votes
1answer
23 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 ...
-1
votes
0answers
23 views

Updating post meta key value not working properly

I'm trying to update a custom field but when I do so it doesn't update correctly. For instance when I type random numbers like 56897, it will only update to 1 number, so it will just become a "5" in ...
0
votes
0answers
14 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
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
251 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 ...
1
vote
4answers
6k views

redirect wp-login.php to another page

I would like to redirect this page wp-login.php to /login page. So when a user clicks on a link like this <a href="/wp-login.php">login</a>, wordpress will redirect him to /register . I ...
0
votes
0answers
14 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
13 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
22 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
33 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', ...
1
vote
1answer
957 views

Auto Populate Custom Field with Complex Value That Increase by One?

Can somebody help me to sort this? I am using WP 3.5.2 and I have "Orders" post type where purchase_order custom field is located. This is the sample of purchase order record: POCOS20130051 PO - ...
0
votes
0answers
14 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
47 views

Is the Wordpress HTTPS Plugin Still Safe To Use?

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
26 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 ...
1
vote
0answers
18 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 ...
0
votes
1answer
21 views

get the post title and print it in the classname

How do you get the post title and print it in the classname using jquery or function code? I wanted to get the post of the title and print it inside may class div name. thankyou
-2
votes
1answer
25 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
35 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
43 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 ...
23
votes
8answers
60k 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 . ...
0
votes
0answers
19 views

Plugin - overwritting entire non-pluggable function

In order to achieve what I want to do with my plugin I need to modify several functions inside comment.php and comment-template.php ( for instance some code lines like if ( is_user_logged_in() ) : ) ...
0
votes
2answers
465 views

How to create an option page for this simple plugin

I know how to write WordPress plugins but I have no idea how we could create an option page for our plugin. I have read lot of tutorials but I still have no idea about creating option pages. So just ...
0
votes
0answers
24 views

Issues with title-tag and document_title_parts

Wordpress version 4.5.1 I'm trying to dynamically update page titles on a particular template. After lots of digging and learning about the wp_title() changes, I'm attempting to use ...