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
votes
1answer
21 views

Trouble figuring out how to get my button to submit comment

I have a text area in the sidebar (sidebar-chat.php) of my posts page with an input that is an image. When this image is clicked, the comment is supposed to submit. I am just having trouble figuring ...
-1
votes
1answer
29 views

How do I add functionality to images?

How would I add functions to images? I host a photography site, in which I'd like to add options to favorite an image or attach it to a product for ordering. Is there a hook or something that I can ...
0
votes
0answers
49 views

get_comments not working properly after WordPress v4.4 update

I just found a wired thing on my website after v4.4 update. In my blog pages I use 2 functions to fetch comments. First I use wp_list_comments( array( "callback" => "checkout_comment", "type" ...
5
votes
2answers
83 views

syntax for remove_filter in parent theme with class

I'm trying to remove a filter on the register_url hook a parent theme added, that seems to have a class nomenclature I can't figure out. Ordinarily, a filter for this hook would be easily added like ...
0
votes
1answer
54 views

insert thumbnail image from php script

I'm trying to insert a post image thumbnail from my php scritp. It's inserting the post, the content, a download link, and I only need to set the thumbnail image to finish my script. This is my code ...
0
votes
0answers
40 views

Active menu item post detail

I'm trying to make the menu item active in WordPress when clicking on a a post item. The way im matching it is based on the browser url and the url of the menu item. However it is making all my menu ...
0
votes
1answer
25 views

How to slow down server response

I've been trying a few methods to slow the loading of my Wordpresss installation by x seconds but I've had problems which each try: Javascript sleep() does the job but my hoster emailed me saying my ...
0
votes
0answers
53 views

Woocommerce “Minimum Order Amount” rule in multiple currencies

Working on a store with base as India (Rs.) but, people can pay in multiple currencies & from multiple countries - but can only ship to a address in India "Minimum Order Amount" for free ...
0
votes
1answer
22 views

custom COOKIE on custom page

i have problem with create function for set cookie dynamically. when i try in custom page i have of course header is set and i tried something like this: in custompage.php: ...
0
votes
1answer
32 views

How to make a cookie be on the whole site instead of being on a specific page/

So I had an idea to make a button that swaps between css files in order to do random stuff such as making 2 backgrounds that the site users will be able to swap between. I had no idea how to do it, ...
0
votes
0answers
17 views

js-methods with prefix specified

I have wordpress plugin with js-file attached for js functions. I want to escape possible error of having js functions with the same name as js functions pf other developers so I use some prefix like ...
1
vote
1answer
143 views

How to change post status from publish to draft using hook in wordpress?

I want to change the status of already publish post to draft using its id. add_action( 'save_post', 'change_post_status', 1 ); function change_post_status( $post_id ){ $my_post = array( ...
1
vote
1answer
91 views

get_post_type() in in_array doesn't work for some reason

I am trying to create some function for metaboxes and some reason i can't get get_post_type to work in in_array. Everything else seems to work in testing but in_array nope. This is the function that ...
0
votes
0answers
46 views

Integrate Stripe api into Bedrock/Sage theme

My question is how do i get WordPress to recognize my new class so i can use it in my charge-card.php AND how do i get it to load Stripe in my actual class, using doesnt seem to work. I'm pulling in ...
0
votes
1answer
61 views

How to debug vars inside function at functions.php file?

I have this function: function wpse_210493_apply_advertising_position( &$posts, $return = false ) { $ad_posts = array(); $content_posts = array_filter( $posts, function ( ...
0
votes
0answers
126 views

Custom post type to display multiple map markers

So I have a google map that I need to display multiple markers on. I have it working with a manual array to display the markers, but now I am trying to make this dynamic using custom post types. ...
0
votes
0answers
25 views

Accordion Menu not being called

I'm trying to add a vertical accordion menu to my custom theme, and I have no idea what is not working. The original tutorial is here : http://cssmenumaker.com/blog/wordpress-accordion-menu-tutorial ...
0
votes
0answers
9 views

How can I enequeue GruntJS concat imagemin output?

After reading countless tutorials and learning how to output solid files using both the concat and imagemin plugins for GruntJS, I have yet to see how I can actually include the output files into my ...
0
votes
1answer
29 views

How to use functions [closed]

I have installed the plugin WPdeposit on my site, it allows users to deposit into their account balance. I am trying to manipulate users balances when they press an anchor tag on the page. In the ...
0
votes
2answers
99 views

Excerpts are not displayed by a shortcode on category pages

A 3rd party plugin that I use adds a shortcode that displays a list of adverts (CPT posts). The shortcode function includes (with an include statement) a template - the list.php file, that displays a ...
0
votes
2answers
42 views

PHP Output also in Child theme, but different

I have a multilingual site setup: www.jeroenbrugman.com The main dutch version uses Fluxus. On the artwork page I output a link using this from Functions.php function prefix_term_name($terms, ...
1
vote
1answer
75 views

Limiting woocommerce line_total decimal length

I am trying to get line_total woocommerce price, but i just cant figure out how to deal with number of decimals. It is now showing price with 4 decimals like 5.5444$ and i want it to show max 2 ...
0
votes
2answers
49 views

how to repeat taxonomy in different places on wordpress

I need help with this. I need repeat taxonomy in two places, are post, and coupones post, this code is in clipper theme. this code put taxonomy stores in coupon. add_action('init', 'clpr_post_type', ...
0
votes
1answer
103 views

Do we need to change our child function.php to require/include child dir files when we add an over-riding file.php into the child theme

With child themes we are supposed to leave parent functions.php in tact and extend it with the child functions.php. However parent functions.php typically define a whole load of include/requires which ...
0
votes
1answer
51 views

Find all strings between an enclosing shortcode

I want to look for all strings in my theme located between my enclosing shortcode [question] desired string [/question]. Then I want to output the so collected strings somewhere in my theme , e.g. ...
0
votes
2answers
58 views

Pass Shortcode Attribute to footer Script

i am trying to generate a wordpress shortcode which will display a (bx)slider. The shortcode function itself works like a charm, i can pass my data and the shortcode gets rendered well. The problem: ...
0
votes
1answer
77 views

using `require` in my functions.php breaks the site

So, I have a snippet of code I'd like to tidy away in a directory that's close to the root my wordpress directory. Specifially it lives in /includes/inc. I've created a file called test.php and ...
0
votes
1answer
34 views

Retrieve a custom form field modified by a filter

I use a 3rd party plugin that creates a form with some fields. I want to use one of these fields in one of my templates. Is there a way to do this? UPDATE I found a solution, see the accepted ...
0
votes
1answer
49 views

Splitting the_content() by size?

I have a situation where users don't want to format quotes in post body and want to just paste their content, assign a quote in a custom field, and the template will now render the quote when viewing ...
0
votes
2answers
18 views

Adding wrapper elements in the_date() like in the_title()?

So this works: the_title( '<h1 class="entry-title">', '</h1>' ); But this does not: the_date( '<h4 class="entry-date">', '</h4>' ); I don't know enough if this is ...
0
votes
1answer
33 views

Make menu structure match page heirarchy on page parent change

Old WordPress themes like twentyten contained functionality which allowed nav menu structure to reflect changes in page heirarchy. For example, if I have the arbitrary page heirarchy (and matching ...
0
votes
1answer
50 views

Improving the perfomance of a plugin action

I want to override a 3rd party plugin action with a new action, but in comments to my another question @pieter-goosen suggested that this plugin action is very very expensive, in terms of using server ...
0
votes
2answers
35 views

Call custom field using php

function the_alt_title($title= '') { $page = get_page_by_title($title); if ($p = get_post_meta($page->ID, "_x_entry_alternate_index_title", true)) { $title = $p; } return ...
2
votes
2answers
194 views

Delete expired posts after a number of days after they expired

I use the below code to delete custom posts with status 'expired' (thanks to Jamie Keefer). Posts are set as 'expired' by a 3rd party plugin. Users have only a frontend access to their posts ...
0
votes
1answer
54 views

wp_create_category deprecated?

Was trying to use this today: WP Create Category https://codex.wordpress.org/Function_Reference/wp_create_category Trying that (which I also assume it's only going to add terms to the built in ...
0
votes
0answers
17 views

function 'wp_heartbeat_set_suspension' not found or invalid function name

Woke up to find this error mysteriously appear on the admin pages of my website Warning: call_user_func_array() expects parameter 1 to be a valid callback function 'wp_heartbeat_set_suspension' not ...
1
vote
2answers
59 views

Two different menus for two different locations?

I'm trying to change the menu in a primary and a secondary menu depending on the page which is visited. My primary menu is in the top of the page, and it looks like this: Index | About | Contact ...
0
votes
0answers
31 views

How set offset on query with specific post_type from functions.php

I have a page template called 'page-blog.php'. On that page I have 2 queries that both obtain the posts of a different post type like so: $posts = ...
0
votes
2answers
47 views

is there a benefit in using a constant over get_stylesheet_directory_uri?

Is there any benefit perfomance wise when defining a constant in the wp-config.php like so <php define('PATH_TO_THEME', get_stylesheet_directory_uri() ); ?> and then referring to ...
0
votes
1answer
59 views

Add URL Rewrite Rule To Wordpress

my link http://localhost/abm/?ct_city=la-jolla&search-listings=true i want to this http://localhost/abm/USA/la-jolla Could you help please.. htpaccss file # BEGIN WordPress <IfModule ...
1
vote
1answer
41 views

How to target only the front page (not subsequent paginated pages) in theme/plugin?

I'd like to switch on the front page ONLY. Not subsequent paginated pages (like ?paged=2). I want to output certain output only on the "true" front page of the site. I've tried: <?php if ...
0
votes
0answers
22 views

Function for moving a sub menu under a different top level menu?

I have a snippet that will allow me to make submenus become top level menus, but can you help with a snippet that will allow to move a submenu to be the submenu of a different top level menu? For ...
1
vote
1answer
77 views

Woocommerce - remove product from category

I'm trying to do the following, but I'm stuck with coding. Hope someone can help me out here. In Woocommerce (on the product-edit page) I can choose in which category the product will be. I made a ...
0
votes
1answer
22 views

Where to put random functions?

I have functions for setting default values when a new user signs up, I have functions for performance testing, I have functions for writing out a small icon to the admin tool bar, and so on. These ...
0
votes
1answer
17 views

Overwriting a plugin function

I need to write a function in my own plugin and overwrite a function from another plugin and (preferably) not make any changes to it. Or WordPress' core. So, basically, what I need to happen is: ...
0
votes
0answers
22 views

How to integrate a code through function

so I'm having this big issue with replacing a code with another via function. I just copy pasted an example code from the plugin developer which at the moment is unable to assist me. This is the code ...
0
votes
2answers
65 views

Adding multiple taxonomy filters to functions.php

I need to add multiple taxonomy filters to the functions.php file to remove (3) irrelevant taxonomies from the Yoast SEO sitemap index. I have been able to successfully add one filter, but when I add ...
0
votes
0answers
22 views

How to get a variable into a buddypress function?

I have a function to create profile subnavtabs in buddypress: function my_custom_subnav() { global $bp; $collection_term = 'FOO'; bp_core_new_subnav_item( array( 'name' => ...
0
votes
0answers
28 views

Pagination not displaying

I'm using HTML5Blank theme to edit my own theme on clean basis, and trying to set the pagination but it's not displaying for some reason, and I cant find out why. Index.php calls loop then pagination ...
0
votes
5answers
823 views

How to run a function every 5 minutes?

I have a function to be run every 5 minutes. I've referred following from the codex: <?php wp_schedule_event(time(), 'hourly', 'my_schedule_hook', $args); ?> I want to run this function just ...