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
15 views

Expanding a function to call a plugin or show a link

I have added the following code to my functions.php to validate if a user is logged in before allowing them to fill out a form: function my_members_only_shortcode($atts, $content = null) { if ...
0
votes
2answers
13 views

Only load certain artists on this page

I have a wordpress page which loads all the artists in two columns... here is what I believe to be the relevant bit of code <?php global $paged; if ( is_front_page() ) { ...
0
votes
1answer
24 views

Nav-Menu not showing up

I would love for somebody to please help me because somewhere I am really miss understanding what WordPress is telling me. Alright so within my header.php I have the following code. <div ...
0
votes
2answers
29 views

Loop Through Categories in Custom Field

Specifically, I am using the add_image_attachment_fields_to_edit function. I have my declaration of label, input.. $form_fields["custom4"]["label"] = __("Custom Select"); ...
0
votes
3answers
65 views

How to use return in my custom function instead of echo

I'm creating a function in functions.php with a custom hook, and from what I've read somewhere, it's good practice to return instead of use echo in a WordPress function? Correct me if I'm wrong. ...
0
votes
1answer
47 views

How to print redirected query string variables to the page?

I have a basic redirection set up: function example_add_rewrite_rules() { $year = '(\d{4})?'; $make = '([a-z]{1,20})'; $model = '(.+)'; add_rewrite_rule( ...
0
votes
1answer
29 views

How to programmatically GET (to know) which Sidebar (or) which Menu is being used on Different Pages?

Lets say i want to detect such thing from the "functions.php" .. to know which Sidebar (or) which Menu is being loaded on current (whatever landed) page, how can i know? Lets say i have a few pages, ...
1
vote
2answers
99 views

Converting HTML Template to Wordpress Theme

While I was trying to convert a Static HTML page to Wordpress Theme , I had an issue . the page Doesn't run properly After Checking Google Chrome Console it turns that it loads the CSS file with the ...
0
votes
0answers
60 views

Can't generate thumbnail images

Having a very strange problem with this site I recently took over hosted on RackSpace. Seems whenever i upload a new image, it doesn't generate different sizes and I'm trying to get it where it will ...
0
votes
1answer
90 views

Call to undefined function get_header() not in index.php

I can call get_header() without trouble in index.php, but not in another file. I got Fatal error: Call to undefined function get_header() in C:\wamp\www\wp-content\themes\Grid\vignette_ibis.php on ...
0
votes
1answer
20 views

How to call a custom taxonomy term name inside a function?

With the following function, the content of another page is included into a page template, which is working fine: // add content of another page function show_post($path) { $post = ...
0
votes
1answer
39 views

How to add a meta information to the URL?

I need to put a post meta information to the URL: www.website.com/custom-taxonomy/postname-[metainfo] How to change the rewrite rules, that the content of this meta information is added to the URL? ...
0
votes
0answers
32 views

Is it possible to change parameters of Parent theme function in the Child theme?

I have a Parent theme with the following function: function getTourOffers($tourId) { global $aitThemeOptions; $params = array( 'post_type' => ...
0
votes
1answer
51 views

Why are some custom javascript files working but some are not

I added some custom javascript files to my wordpress page. I put them in the funcstions.php like this: wp_register_script('formfunctions', get_template_directory_uri() . '/js/formfunctions.js', ...
0
votes
0answers
7 views

How to make child class use the same signature? [duplicate]

functions.php class themeslug_walker_nav_menu extends Walker_Nav_Menu { function start_lvl(&$output, $depth, $args) { $indent = str_repeat("\t", $depth); if('primary' == ...
0
votes
1answer
51 views

WordPress dynamic AJAX query

Aim - I've trying to run a query based on which category is selected from the dropdown. I figure the best way to do this, is to dynamically use AJAX and pass the category value held by a variable to ...
0
votes
0answers
25 views

get_comments function returns diffrent values on different accounts, why?

If I am on my admin user, the function get_comments() returns the array of comments in the template, but for the subscriber, the array is just empty. I tried to add permission to the user but it ...
0
votes
0answers
10 views

RSS Feed Notifications

I'm creating a site that pulls RSS feeds from various blogs & displays their latest posts. On the category/archive pages, I'd like to show a small notification on each post whenever there is a new ...
3
votes
1answer
125 views

How to display random users with avatars

I adapted a little a function to display a number of random users with their avatars with a shortcode. It works, but something is not good. Sometimes it displays with one user less than I want (just a ...
1
vote
5answers
237 views

Display height and width properties with the_post_thumbnail() or related function

Problem I want the height and width properties in the img element of the Featured Image for a post, page, or custom post type. Environment I have a custom theme based on the BlankSlate theme. The ...
0
votes
0answers
45 views

custom function for wp_list_categories

I need to write a custom function for wp_list_categories so instead of displaying a hierarchical list of links they are instead a list of checkboxes with the parent terms being displayed as h3 tags. ...
0
votes
1answer
87 views

How to override a theme function (within a class) using a plugin

I am working a website which utilises a highly complex theme (essentially a whole bunch of other software tacked onto Wordpress), so complex in fact, that child themes wont work with it. I want to ...
0
votes
0answers
30 views

Problems after changing URL from my-site.net/blog to my-site.net

After I changed site url (in general settings) to http://www.my-site.net I can't access my wp dashboard and my site is loaded very slow and only HTML elements are loaded First thing that I did was ...
0
votes
0answers
25 views

do_action filter function from add_action array

I am looking at the following setup: -- Combing multiple functions into single action -- add_action( 'single_post_meta_start', array( $this, 'the_title' ), 10 ); add_action( ...
1
vote
0answers
35 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
1answer
28 views

Getting error while trying to use custom comment function

I'm trying to write a function that will allow me more control over the display of comments on a post page. However I'm confused about how to set it up so WordPress can use it. right now I get the ...
0
votes
2answers
58 views

Use Exact Image Size using add_image_size

I have a pretty basic question. It may be very noob question, but it is bothering me a lot. In my theme I've added a custom image size like this: function img_update() { if ( function_exists( ...
0
votes
1answer
31 views

Custom image size in Media Dropdown

I've tried everything you have said, but it's not working on my site. I'm using the below function: function setup_image_sizes() { if ( function_exists( 'add_image_size' ) ) { ...
1
vote
2answers
248 views

Upload Multiple Files With media_handle_upload

I have a WordPress form plugin and I use media_handle_upload to upload the files and get there ids directly and attached its ids to the post as a meta date, I used the following to did that: The HTML ...
2
votes
2answers
48 views

Editor access to plugin settings

I'm trying to give access to an user with the role Editor to this plugin settings page: https://wordpress.org/plugins/commenter-data/ In the code of this plugin on line 31 of commenter.php there is ...
0
votes
1answer
26 views

Plugin Development - Functions or Hooks?

I am brand new to WordPress plugin development and have a few questions, mostly about best practices but also some specifics. Essentially I just want to trigger an action (invoking a PHP class and ...
0
votes
0answers
57 views

Error function main() is a non-object to construct my Ajax.php

Try to use a "rapid" ajax, I've the follow code in my my-ajax.php file define('SHORTINIT',true); require_once ('../../../../wp-load.php'); require_once ('../../../../wp-config.php'); require_once ...
1
vote
0answers
42 views

Overwrite Parent Theme add_image_size in Child Theme

I'm using a child theme of a parent theme. Now on my parent theme, theveloper adds some custom image sizes like this - if ( function_exists( 'add_image_size' ) ) { add_image_size( ...
0
votes
2answers
62 views

Show different website layout if no sidebar added

I have a question about website layout with and without wp widges in sidebar. Here is the code i have for my registered sidebar. <?php if ( !function_exists('dynamic_sidebar') || ...
0
votes
1answer
33 views

How do I place a function in a standalone page?

Im trying to a a function to create an rss feed from a gmail dress. This works if i place it in functions.php, but overtakes my site as an rssfeed, as expected. How do I place it in a standalone page, ...
0
votes
1answer
25 views

Problem in using Customizer

Looking for some help with a customizer problem. I am using following codes to create a customizer which will allow me to upload an image for topic of the week section. owever, the following codes ...
0
votes
1answer
32 views

Load WP Admin scripts in a child theme functions file

All, I'm using a plugin that enqueues some scripts in the admin section of wordpress. I want the same functionality built in a page template. I noticed the main difference between is it tries to use ...
1
vote
1answer
59 views

changing behaviour of get_search_form

I created a function to display a search box and named it my_get_search_form() that is a copy of original get_search_form() function. when I call the function, the output is this: Search in ...
0
votes
1answer
38 views

How to call particular funcion when the check box is checked in plugin options page

I'm new to php and wp plugin development, i just created a simple options page for my test plugin, the options page has only one check box, i don't know how to execute some function when the box is ...
0
votes
1answer
28 views

How can we know we are not in edit page

I want to enqueue a JS file only to my View Page screen(after pubishing page). Whenever I click on edit this page, i want to remove that JS. How can we do this. `if(is_page()){ wp_register_script( ...
0
votes
0answers
25 views

Create a random list of html items within a shortcode in the functions file.

I'm trying to create a function that randomly pulls lines of code for a list of HTML items. Basically, I'm going to have a list of 50 or 100 images with hyperlinks associated with them. I'd like a ...
4
votes
2answers
33 views

Check if the user has explicitly set an excerpt

Is there a way for me to check if the user has explicitly set an excerpt? I need to call the excerpt only if they've specified something in the excerpt field, and not an automatically shortened ...
0
votes
1answer
63 views

Why doesn't is_page(id) work in functions.php?

When is code in functions.php executed? Is it during the loop? The following does not work when placed in functions.php (not within a function) : if (is_page( 27 )) { echo 'this is the apply page'; ...
0
votes
2answers
48 views

Can't Write Custom Widget Code In One ECHO

I am creating a WordPress custom widget and I created the below one that is working fine when I add it in function.php. <?php /* ...
0
votes
0answers
162 views

Function to add image link from php to fancybox js

I've got a single-cpt.php page on my website that has a photos' section this needs to display multiple images of the product/location. At the moment when the photo thumbnail loads a lightbox comes up ...
0
votes
1answer
36 views

Nested shortCode functions in the functions.php file

I'm trying to get a shortcode function (newStuff) to display inside of another function (oldStuff), but I'm running into trouble. Both shortCode functions are listed below, as well as what I've tried. ...
0
votes
0answers
8 views

Accessing current post data through a function

I'm using ninjaforms on my wordpress site and i have a form that is displayed on my post template. The idea behind the form is give the user a PDF file once they have completed the form. I need to ...
0
votes
1answer
38 views

Problem with custom function when I go back with the browser

I have a custom function inside functions.php to show the typical social media buttons for each post listed (last entries, categories and tags pages): //Social Media function showSocialButtons() { ...
5
votes
2answers
164 views

remove_action on after_setup_theme not working from child theme

I am trying to remove a theme action for an elegant-themes theme using a child theme.. This works when I remove action after add_action code anywhere in the parent theme functions.php. However, it ...
0
votes
0answers
50 views

List Most Read Posts from last 7 days (with custom post type and other meta queries)

I am using following code in my functions.php to count the views of the post. // function to display number of posts. function getPostViews($postID){ $count_key = 'post_views_count'; $count = ...