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)

2
votes
1answer
60 views

Check if page parent has certain template

I want to check if a page has a parent with a certain page template attached to it. If I know that I can determine which scripts to load or not. Normally I would just get the page template and if it ...
0
votes
0answers
41 views

Enable/disable code in functions.php with options

Is there a way to enable or disable lines of code in a themes functions.php file? Basically I would like to have a page in the admin panel that lists "modules" or separate php files and has the ...
3
votes
1answer
47 views

Add options to featured image

I want to add an option to the featured image metabox. I have found a way to do this here The problem I'm having is saving the value tot the database. Here is what I have tried: add_filter( ...
1
vote
1answer
35 views

Creating loop within functions.php

I'm using Woocommerce on my website, on the checkout page I've got a custom select checkout field with radio buttons. I'm using this working snippet within my functions.php: /** * Add the field to ...
1
vote
1answer
33 views

How do I remove the date and category form my portfolio pages

This is one of my portfolio page Whenever I wanted to remove dates and category from blog posts I always used this code function jl_remove_post_dates() { add_filter('the_date', ...
1
vote
0answers
25 views

Adding a widget function into the php theme file

I am using the following plugin - widget No Cache AJAX Widgets to display on the sidebar a feed of rss news that is created dynamically and bypassing the cache function. In updating the site we wish ...
3
votes
1answer
34 views

Wrap each shortcode in array to div

i'm trying to wrap each shortcode in div with special data attributes, but when i'm using nested shortcode they don't wrapped, where i'm wrong? thanks public function wrapShortcode( $content ) { ...
1
vote
1answer
46 views

Redirect to another page if the user is logged in when pressing again the login button on menu bar

So I have this button on the menu : "My account" that lets the user login on the website and as soon they log in they're redirect to their dashboard. What I'm trying to achieve is if he's logged in ...
0
votes
2answers
45 views

How do I correct the code in php? [closed]

I am new to PHP and I'm unable to solve the code. It's showing an error. <?php function thumbImg() { if ( has_post_thumbnail() ) { the_post_thumbnail( array(54,54) ); } else { ...
1
vote
1answer
30 views

Custom Shortcode, functions PHP WP_Query loop

I have the following code in my functions.php file:- function featured_properties_func( $atts ) { $args = array( 'posts_per_page'=> -1, 'post_type' => 'properties', ...
1
vote
0answers
38 views

Update user profile information from functions.php

I have the following function in my functions.php file:- function apply_for_job() { $job_id = $_GET['job_id']; $user_id = get_current_user_id(); $prev_value = get_field('applied_jobs'); ...
1
vote
0answers
12 views

Homepage's content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?

I have a custom field in my home page called "Featured posts". There are two fields: title and post. The post field returns post_object with post_type as posts. In my functions.php I have added the ...
1
vote
0answers
28 views

add_action shortcut?

I think in PHP 5.4 or above (don't remember the exact version), instead of writing: function some_function() { } add_action( 'init', 'some_function' ); One can pass an anonymous function: ...
0
votes
1answer
36 views

Limit dimensions of “Full” size images

Is there a way to limit the dimensions of the full size uploaded image (made normally through the Media library)? I have clients that upload huge images files with resolutions sometimes greater than ...
1
vote
0answers
27 views

Get First Child Page ID or Permalink in WordPress Admin

I have a navigation set where the content doesn't exist on the parent page, but rather on a page called Overview which is the first child of the parent. eg: About is the first level page, but when ...
1
vote
1answer
35 views

Override the function twentytwelve_scripts_styles in a child theme

I want to overide the function which enqueues scripts and styles in the theme Twenty Twelve using its child functions.php. I followed this guide but can't get it to work. Can someone suggest a ...
1
vote
1answer
20 views

Missing Argument

I have the following code in my functions.php to show a lightbox on the Simple Paypal Shopping Cart Plugin function make_wpspsc_thumbs_lightbox_previews( $thumbnail, $atts ) { // Code Credit: ...
2
votes
1answer
30 views

how to change link of some wordpress pages

I've made templates for the pages of my wordpress site such as: singup,signin,suggestions. Default wordpress pages link is as follows: doamin.com/signup/ or doamin.com/signin/ or ...
3
votes
1answer
79 views

Displaying post per day

Currently I have the code displayed below. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12"> <a ...
0
votes
2answers
109 views

Woocommerce checkout field maxlength, make input number field only (postcode)

I've been struggling with this for a few days now. What i want to do, it to limit the Postcode/zip fields to 4 numbers. So, to add a maxlength and a type="number" to those fields. Things i've tried ...
1
vote
0answers
34 views

Dynamically change feature image in customiser

For this client's Website I am making on their homepage there is a section called featured products with images showing off the product. Currently I have to update these images manually through my ...
1
vote
0answers
33 views

WordPress Quick Question . How to Get Parent Link in Submenu in My Code

I'm creating a menu walker from foundation 6 but problem is parent link is not click able, so solution might be that if we can get parent link in submenu but have some problem because I'm don't know ...
1
vote
0answers
37 views

Get the date of the className or classID

Is it possible to get the date of the class name or class ID? I just used the following to get the date of the post, but there are image galleries and each image has a different upload date: echo ...
0
votes
0answers
7 views

Cachebust child theme stylesheet queston

I am using the below to cachebust my child theme stylesheet with a version number. I noticed that Wordpress continues to try and load my original child stylesheet "style.css" in the head even though ...
1
vote
1answer
31 views

Footer disappears when using the_content ( )

I have an issue when using the_content() -- the footer of the page disappears and no errors are displayed. When I change the_content() to get_the_content() and echo this results then it works fine. ...
1
vote
0answers
15 views

How to assign a customer to an order?

I have a problem assigning a customer to an order using a php script. Is it even possible? I know, that it is possible to get the customer ID back from the order, but I can't find a way, how to set ...
1
vote
1answer
34 views

Having issues with a foreach inside of a shortcode with ACF gallery

Normally I would just put this type of content in a template, but the way I'm pulling in the content is a bit different. I made a shortcode which I've been having issues with. It's using Foundation ...
1
vote
1answer
1k views

How to display custom field in woocommerce orders in admin panel?

currently i add a custom billing field in woocommerce by function custom_override_checkout_fields( $fields ) { $fields['billing']['billing_phone_new'] = array( 'label' => ...
1
vote
0answers
16 views

Full page template function

I would like to be able to create page templates that all look almost the same, and have a template I would like to use. I would only like to change certain fields for the page, for example: header ...
1
vote
1answer
59 views

Child theme functions.php not executing

I have the following in a child theme's functions.php file: <?php function theme_child_add_scripts() { wp_register_script( 'script', get_stylesheet_directory_uri() . ...
2
votes
0answers
69 views

How to override a function when isn't at functions.php

I am trying to override a function for a theme in the child-theme but I can't get it to work. At functions.php on the theme I can see this require_once line: ...
1
vote
1answer
91 views

Set quantity of woocommerce product on page visit

I'm trying to set the quantity of a product on visiting a page. If the product isn't in the basket, the code works fine and adds the correct quantity. However, if I have anything in the basket and ...
1
vote
1answer
27 views

Get page id or status by private pages?

How can I get post id or status by private pages if user is not logged in? This don't works: get_the_ID() get_post_status ( $ID ) I found some usefull informatins here but is not enough to detect ...
1
vote
0answers
36 views

Redirect from “private” page and functions.php which tag add to add_action()?

If someone try to open a private page as guest user he says only "Oops! That page can’t be found.", I want to redirect it to a exact page, I try to do it in functions.php but I'm confused what to add ...
2
votes
1answer
34 views

Limit filter upgrader_post_install to a single plugin

I am using the following filter to run a function that generates a CSS file after a plugin gets updated. Currently the CSS gets generated when any plugin gets updated. Is there a simple way to limit ...
1
vote
1answer
34 views

function to erase swear words

Does anyone use a function that will just not print swear words? We don't have any, and we edit for them, but in giving more writers more publishing privileges, it could lead to a situation with swear ...
1
vote
1answer
111 views

How to pass “get_the_terms_list” as shortcode to Visual Composer Grid Builder

I am trying to create a shortcode that returns the term list inside of Visual Composer's Grid Builder. I have read the docs here. My code is as follows: add_filter( 'vc_grid_item_shortcodes', ...
0
votes
2answers
165 views

In WooCommerce I need to modify the thankyou.php page [on hold]

In the thankyou.php template there is an action showing the section marked in red in the image. The problem is the caption/title "Our Bank Detals" should be above the description not beneath. The ...
2
votes
1answer
45 views

How to Add a Random Custom Gravatar in the WordPress Comments?

I have a client that has 5 different gravatar images, and would like them to be randomly used as the thumbnail for people's comments that have no Gravatar. I know how to change the Gravatar to a ...
1
vote
0answers
26 views

meta_query not working as expected

I have 3 posts that each have two meta values. The first meta value is one that they all share (ac_parent_event). The second is one that is unique to that post (ac_thischild_date). For this function, ...
1
vote
1answer
45 views

My new button is in the wrong place

Initially, I was trying to have the "Add to Cart" button change to "Make an Inquiry" based on the condition of availability and whether there was a price inputted, or not. I kind of got the ...
1
vote
0answers
31 views

Can't find infinite loop cause

I am working on the below function which will eventually create a set of posts based on meta data entered into a "parent" post. I'm running into an infinite loop when hitting the save button, which I ...
6
votes
1answer
146 views

Does hooking into the same action multiple times drain memory?

Currently I have three functions that run on pre_get_posts. I call them like this: add_action( 'pre_get_posts', 'private_groups' ); add_action( 'pre_get_posts', 'search_results' ); add_action( ...
-1
votes
2answers
44 views

load_plugin_textdomain error

I receive this error while debug mode is enabled: Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in ...
1
vote
1answer
22 views

Unique sequential reservation code

I have a situation where I'm re building a tour transfer reservation site, I've created the reservations cpt's and each time a user place a reservations this automatically post as a new reservation. ...
1
vote
0answers
46 views

bulk change of image setting “link to” to “link to: image url ”

i want every image present on my wordpress site with setting "link to: none" or "link to: post url" became in "link to :image url" ho make this for old post and for new post ? i tried this code in ...
1
vote
1answer
46 views

Cannot save CPT meta box

I swear I have tried every tutorial, and looked through every Stack Overflow thread to figure out what I'm doing wrong... I'm creating a custom wordpress backend for a church that includes a place for ...
1
vote
0answers
42 views

Displaying Login form with Shortcode

So I am trying to display a working version of the default wordpress login form on one of my pages. There is code in the functions.php file that creates the shortcode and as far as I know it works ...
1
vote
0answers
20 views

Categories as main menu items and subcategories as nested lists

I am new to WordPress and am trying to make my website. Would it be possible to list categories and subcategories as a nested list with links in the main navigation menu. What am i trying to achieve ...
1
vote
1answer
29 views

Multiple Loops Inside a Function

What I understand from the CODEX, (https://codex.wordpress.org/Class_Reference/WP_Query#Multiple_Loops). then I'm trying to do a list of posts like this: <nav id="cbp-hrmenu" class="cbp-hrmenu ...