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
0answers
14 views

Function returning same value for all posts

I have this function to get the size in KB from a file. It works like a charm as long as it's on a single post. However, if I do a query, all posts take the value from the first post. Thus, if the ...
1
vote
1answer
20 views

IF Statement in Wordpress

I can't seem how to correctly use the php if statemnt in my add filter function below. This code works perfectly if all (3) of my $_POST inputs have values however it has a fatal error if any are ...
0
votes
0answers
10 views

Entire site breaks when bug in .php because of multiple get_template_part in functions

I bought a wordpress template and I'm modifying it to suit my needs, but I have a problem. Whenever I left a bug in one .php, the entire site (including the homepage) breaks. I see that the way the ...
0
votes
1answer
14 views

Displaying text if post was within 5 hours

Currently I have the following string. $timeago = human_time_diff( get_the_time('U'), current_time('timestamp') ); print $timeago; This returns results that looks like this. 1 min, 1 hour, 1 week, ...
0
votes
0answers
16 views

Javascript attr href not appending parameters on WordPress site

I have this exact code set up and running on a regular HTML/PHP site but when I tried setting it up in WordPress, it doesn't work. The code itself works, the Javascript is present when I view the ...
4
votes
1answer
35 views

Paged Single Post doesn't redirect to the main url after Removing Pagination

I used <!--nextpage--> (Codex) to paginate (split) a few single posts. Now i removed all the nextpage html parts from the posts. everthing looks fine. Unfortunately the old urls like ...
0
votes
0answers
23 views

Add multiple filter using preg_replace_callback to image tags in single post

Im successfully using the following code (without plugin) in my functions.php to defer load my images in the single post content ($content) area. function filter_defer_loading($content) { return ...
0
votes
0answers
13 views

add_menu_page and URL parameter

It is possible in WordPress to add a url parameter to the add_menu_page slug? Only found solutions for a submenu page. Odd thing is that if i add a node to the admin bar which has the link ...
-1
votes
0answers
16 views

Modify (functions) code that inserts ads (or whatever else)

I use the following code in functions.php to insert an ad after the second paragraph. I would like to continue to do this, but also add another (different) ad before the last paragraph. How do you ...
0
votes
0answers
12 views

Custom Gallery HTML only returns #carousel output and not #sliding ouput

I took the following code from an example and adjusted it so a standard gallery in wordpress would output as a Flexslider and Carousel. I can output one of them just fine, but I added additional ...
0
votes
0answers
22 views

Custom WP Admin pages do not display after trying to add child to functions-admin.php

I am building a theme options page. I have a parent page with 3 sub-pages under that. Volcano (Parent) Sidebar Theme Options Custom CSS The Problem: All of these settings are not displaying at ...
1
vote
2answers
26 views

Change size and crop medium_large images

I use events manager pro plugin to show an eventslist. These event-list is showing their thumbnail image in the new (wordpress 4.4) wordpress image size "medium_large" (width 768px). I need an image ...
1
vote
0answers
18 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
17 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 ...
-2
votes
0answers
13 views

How to get Fpdf,html2pdf or Dompdf get work in Wordpress custom template?

Im working on a project to let html input change into a pdf file. I know that are these working pdf programms, but how do i put it in Wordpress and let it work in there?
3
votes
1answer
33 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
27 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
27 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
11 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
27 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
votes
0answers
15 views

Woocommerce Layered nav filter attributes not being included in a search by a custom field

I have extended the search to include custom fields on each product following guidance from this article: http://jamescollings.co.uk/blog/extending-woocommerce-search-query-include-custom-fields/ It ...
1
vote
1answer
18 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
41 views

How do I correct the code in php? [on hold]

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
27 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
14 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
19 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
10 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
31 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
18 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: ...
0
votes
0answers
10 views

Multiple relationships pods issue

I'm new at using Pods, which I find very practical. I'm experiencing some issues though; I'd like to create a model like the following-one : Entity type 1 |->sub-entity type a, refers to a specific ...
2
votes
1answer
26 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
60 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
1answer
24 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
24 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
17 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
36 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
6 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
13 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
19 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
87 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
15 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
49 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
32 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
19 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
16 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
23 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
29 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 ...