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)

1
vote
0answers
5 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 ...
1
vote
1answer
15 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
18 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
37 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
24 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
31 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') || ...
-1
votes
0answers
4 views

How can I use Same Category but different size image thumbnail [on hold]

I want to make a news website. Please help me by giving my answer
0
votes
1answer
26 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, ...
-4
votes
0answers
10 views

Is there any wordpress plugin for reference user get discount on any purchase? [closed]

Like, there is user who register with site and it takes one unique ID. That user give that ID to their friend and advice to register with that reference ID. And after registration of new user with ...
0
votes
1answer
15 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
16 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
22 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
24 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
24 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
12 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 ...
3
votes
2answers
24 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
29 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
34 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
20 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
22 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
7 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
36 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() { ...
4
votes
2answers
88 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
33 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 = ...
0
votes
0answers
15 views

Adding stick post button to edit post page

Right now, posts can only be sticky through the quick edit panel. Can I add a sticky checkbox to the post edit page?
0
votes
0answers
78 views

Adding jQuery datepicker to Custom Post Type Metabox

I've created a custom post type metabox which displays and functions fine. The problem is with the datepicker it just doesn't seem to work, when clicking the metabox youre able to type in it rather ...
0
votes
1answer
29 views

add_role menu pages are not visible

I added a custom role this way: add_role( 'tabellenadmin', __( 'Tabellenadministrator' ), array( 'activate_plugins' => true, 'delete_others_pages' => true, 'delete_others_posts' ...
0
votes
1answer
21 views

Ajax resetting my global variable

I am wondering why I can't read the updated value of $_TEST. It seems that $_TEST is being reset with each Ajax call. // functions.php $_TEST = 0; // the variable I want to update with each Ajax ...
0
votes
2answers
30 views

Function to limit number of custom post types on homepage - TwentyTen

here is the deal... I got hold of this piece of code to change the default post type shown on my TwentyTen child theme's homepage. It works like a charm when I add this code to the functions.php ...
0
votes
0answers
36 views

Incorrect output with get_attached_file()

I am having troubles with file encodings while retrieving file names with get_attached_file(). The line: get_attached_file( $attachment_id ); Is getting me results like: ...
0
votes
1answer
27 views

shorthand syntax for custom fields

I'm trying to write a shortcode and am sorely out of practice with this stuff. It's for a plugin Full Width Audio Player and I'm trying to query all tracks within a certain playlist so it will output ...
0
votes
0answers
10 views

Call plugin function from button and then forward

I'm new to WordPress plugin development (new to PHP in general) and I'm looking for my plugin to run some if checks and then forward to a new page after a submit/button was clicked. I am currently ...
0
votes
1answer
45 views

Navigate posts with different post type that are in the same categories

I created two custom post types that share the same category taxonomy. I'm using next_post_link() and previous_post_link() to navigate through posts with the same category but it only works for ...
0
votes
1answer
24 views

While loop with an exception after a count is reached

I'm trying to edit the tag.php page so that it displays all tagged posts (as it normally does) 'but' I want to call a function after the 3rd post in the loop. Current Code <?php /* The loop */ ...
-1
votes
1answer
19 views

Display function from functions.php in tag.php

I've added several functions to the functions.php file. I call those functions using a shortcode [shortCode] while in posts, pages, and widgets. But the [shortcode] will not work outside of posts, ...
0
votes
1answer
23 views

Preventing PHP Execution in Parent Theme

I have set up a child theme to make custom changes to my site without having them erased every time I update. One change is to remove a wrapper that displays the title of the page with a lot of white ...
1
vote
0answers
61 views

Create post using Ajax

I want to create post using Ajax . I had followed the process from Insert Post using Ajax But I couldn't make it work. Here is what I did. Please see what I did wrong as I am just a learner. EDIT ...
0
votes
0answers
11 views

check value on external url - WP

i need a form feeld on WP page to enter a code. this code must be checkt on a external url. So as example the code is: 4445000000395 it must be checked on: ...
0
votes
2answers
35 views

Excerpt length: get 2 paragraphs

I have successfully implemented a solution from WPSE that trims the except to the first paragraph, but I'd like to change that to trim after the second paragraph instead. There's a link floating ...
0
votes
0answers
34 views

Sanitize html, where to sanitize

I have a function that returns an style=".." html attribute. I am not sure how to sanitize. Here is the code: functions.php function zz_style($properties, $values) { $styles_array = array(); ...
0
votes
0answers
18 views

My function ajax only be called only once

Well...I've one problem when I using ajax in wordpress. I'm using ajax when in the site anybody will send me a email (like a contact). I used my function in my page "Contact" and it's works. But I ...
0
votes
0answers
26 views

function get_page_permastruct() on a non-object

global $user_ID; $page['post_type'] = 'page'; $page['post_content'] = "Hello world"; $page['post_parent'] ...
0
votes
2answers
50 views

Retrieve post modified date for specific post by post ID

I am looking to use the 'the_modified_date' function to display the date and time of a specific post has been modified. This information will appear in the header of our website on every single page. ...
0
votes
1answer
16 views

Settings in functions.php used by a plugin

I'm writing a simple plugin and want some settings in an array in the functions.php file. I'm thinking of adding this in the theme functions.php $test = array('haha' => 'hehe'); my_function( ...
0
votes
0answers
29 views

How to make a plugin theme-wide?

I have written a working plugin and meets the criteria. Although I've encountered an issue, I've noticed that it's only usable on the theme's functions.php that I write the function and specify the ...
0
votes
1answer
28 views

Ajax call theme functions from front

Here's what I try to do : calling a function in my theme functions.php from the front of my theme. So, on the front : $(document).on('click','.btn-vote',function(e){ ...
1
vote
3answers
158 views

Rewrite Question Mark in Post Template with URL Parameter for clean URLs

I use following code (Source) to change the single post template via url parameter: function sjc_add_query_vars($vars) { return array('template') + $vars; } add_filter('query_vars', ...
0
votes
1answer
37 views

Creating customized php files in theme folder

I am developing a e-commerce theme that requires an order page. I created a php file inside my theme folder named order-page.php and hope to access this page from the wordpress root url ...
0
votes
1answer
18 views

Format latest/newest post differently

I need to apply different formatting to only the latest/newest post. I need the first post to be full size image and full post, all subsequent posts must be excerpts with thumbnails. The code I am ...
1
vote
2answers
43 views

Fatal error: Class not found in

I am working on a plugin for 'hooking' an extra payment provider into a checkout system. I have a class gtpCheckoutData in my function.php which calculates the prices. In my plugin I want to use ...