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
54 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
46 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
40 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'); ...
0
votes
1answer
3k views

Visual Composer creating own shortcodes with vc_map() to return simple Image

I am using the Plugin Visual Composer with in a new Theme I develop. My question is about mapping shortcodes to Visual Composer arrays. The problem I get, when I try to make a custom element for an ...
0
votes
2answers
430 views

Shortcode to find and replace URL

I'm trying to create a shortcode that will search within some specified text for a link and replace it with one that I specify. For example: [scode]Click on <a href="www.X.com">this link</a&...
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
34 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 ...
2
votes
2answers
889 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); ...
3
votes
1answer
20 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
36 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 ...
3
votes
1answer
938 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
3answers
82 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
26 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
35 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
27 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
77 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
23 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 ...
1
vote
2answers
652 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
24 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
299 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
16 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
15 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
30 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
38 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
15 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
54 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
27 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
21 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
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
37 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
46 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 ...
25
votes
8answers
62k 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
0answers
45 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 ...
1
vote
2answers
3k views

Function to return true if current page has child pages

I'm trying to create a simple function to do a "status test". Goal is to test and see if the current page being viewed has any child pages or not. Using this to alter layout to accomodate child ...
0
votes
0answers
19 views

Echo multiple tasks if a common function exists

How can I echo multiple tasks if a common WordPress function exists. For example, I want to reduce the following: <?php if (function_exists ('pluginName')) echo someName (1); ?> <?php if (...
0
votes
2answers
23 views

Email Exists ERROR into Ajax registration form

My problem is that I can't verify if some user insert an existing email into AJAX registration form. However my form is working fine, it's registering users and it's giving all other errors, like "...
0
votes
0answers
20 views

get_pages() shows either ALL pages or just main-menu

I'm losing the battle with get_pages(). What I'd like is a list of child pages to display on each main-menu parent page. I'm trying get_pages() rather than wp_list_pages() as I'd like to be able to ...
1
vote
1answer
490 views

Warning: array_pop() expects parameter 1 to be array, boolean given

Getting the following php error when trying to add a new post: Warning: array_pop() expects parameter 1 to be array, boolean given in /home/mysite/public_html/blog/wp-content/themes/mytheme/...
0
votes
1answer
28 views

Show modified time if post is actually modified

I want to display post updated time only if post is modified, I am using function the_modified_time() . So I just read about that there is if statement that can be used to check if post is even ...
1
vote
0answers
106 views

Override a theme function in a child theme?

Most if not all of the answers to this question are pretty old, or are for edge cases. I have a child theme for a commercial theme ("Total"). The parent theme's functions.php loads functions from ...
0
votes
0answers
46 views

Add post order to function

How to add post order to this function? I would like to display most recent post from newest to oldest: <?php //Establish first post check variable $first_post = true; query_posts('category_name=...
1
vote
1answer
41 views

How to stop images from being wrapped in <p> tags?

I'm trying to stop Wordpress from automatically wrapping <img>s with <p> tags. I've tried this often-reccomended snippet from around the web in my functions.php: function ...
0
votes
1answer
56 views

How to add aria role and schema markup to custom walker container

Edit: after doing some research I've found that in the wp_nav_menu function uses the following code to display the containers value. if ( $args->container ) { /** * Filter the list of ...
0
votes
2answers
36 views

Problem with images URL after filter applying

I have this code in my functions.php file: function user_content_replace($content) { // it's not a URL, let's apply the replacement if (!filter_var($string, FILTER_VALIDATE_URL)) { $...
1
vote
1answer
21 views

Count the number of times the search form template gets included on a page

I've got a template that has a search form in several locations. Each search form is identical, containing a text input, two radio buttons, two labels associated to the radio buttons, and a submit ...