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)

-4
votes
0answers
10 views

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

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
14 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
14 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
0answers
17 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
23 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
23 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
28 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
0answers
19 views

Advanced Custom Fields: First option automatically checked with dynamic checkboxes [closed]

I am using the plugin Advanced Custom Fields on my site. I am using this tutorial to automatically generate a list of checkbox options based on a set of repeater values on the ‘Options’ page. Even ...
0
votes
2answers
31 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
14 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
21 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
35 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
82 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
27 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
14 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
65 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
28 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
18 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
27 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
26 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
42 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
22 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 ...
0
votes
0answers
50 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
34 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
30 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
13 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
46 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
28 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
156 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
42 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 ...
0
votes
0answers
37 views

setcookie in functions.php does not accept arguments (variables) passed from WordPress page

I have a WordPress installation where a page (Page 1) displays certain fields from a selected user's profile (Not the logged in user but a user they have selected). A PayPal button is used to take a ...
1
vote
1answer
28 views

Set the background to a default image if there isn't a specified “featured image”

I am having a little trouble displaying a default image as a background image when a feature image is not present. This is the code I am using <?php if (has_post_thumbnail( $post->ID ) ): ...
0
votes
1answer
20 views

Remove heading tags on line break

I have to add line breaks in a h1 paragraph using the visual editor. On every line break Wordpress automatically adds h1 tags to every new line. Example: <h1>Watsup</h1> ...
1
vote
1answer
63 views

Remove function or filter

Im working with a child-theme of Wordpress-Bootstrap by 320press.com I want to get rid of the lead class added to the first paragraph of the content. I looked in Wordpress codex in these articles: ...
0
votes
2answers
32 views

How do I pull avatar from post using BuddyPress? [closed]

I'd like to pull the avatar of a blog post's author and display it on the page using BuddyPress but I cannot seem to pull it off. How would I go about this?
0
votes
0answers
37 views

Display a post based on its metabox selection

I created a client portal where a client can view their projects. I have two user accounts "Clients" and "Administrator. Both clients and administrator are redirected to the frontend of the site to a ...
5
votes
2answers
85 views

Is there a hook or function I can use to display all theme files being used on a current page?

Basically I want to be able to see the names of files on the front-end - not just templates e.g. category/page templates, but the actual theme files like header.php/sidebar.php/footer.php and so on. ...