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
2answers
653 views

Update user meta of author when post content is viewed

I have a value that I'm trying to store as user meta for authors on my site. I need it to update itself every time the content of a post is viewed for that author. Here's as far as I've gotten but it ...
-1
votes
0answers
16 views

Does functions.php apply to every page?

I am currently trying to add a slider onto my homepage using the Meta Slider plugin but I am also using this code below in my functions.php of my storefront-child theme. But the slider is being added ...
1
vote
1answer
72 views

wp_enqueue JavaScript in child-theme (ReferenceError) using Search & Go

This is my first post here, so I hope I pasted the code well and you'll stand by interpreting the problem. I have deregistered and dequeued two scripts in my childtheme. When removing and adding ...
0
votes
0answers
10 views

How to include a plugin's (MailPoet) javascripts using child theme's functions.php

I have to include some javasripts files in all pages of my website. They are required by MailPoet to handle newsletter subscriptions. Now, I may add them directly into the head section, but I'd like ...
4
votes
4answers
190 views

Issues with title-tag and document_title_parts

Wordpress version 4.5.1 I'm trying to dynamically update page titles on a particular template. After lots of digging and learning about the wp_title() changes, I'm attempting to use ...
0
votes
1answer
8 views

How to use Internationalized human_time_diff() function in Chinese?

Looking at https://codex.wordpress.org/Function_Reference/human_time_diff I'm using an English version of Wordpress. In my theme template, I would like to define custom text of min, hour, day, week, ...
0
votes
1answer
33 views

I want to replace a word with another word in my entire WordPress theme

I have a WordPress freelancers theme and I want to write a function that replaces the word "freelancer" or "freelancers" with the word "creatizen" or "creatizens". I am a pure newbie so I would ...
1
vote
3answers
5k views

Getting the post_id in wp_ajax function

I wrote a custom AJAX function in which I have assigned a post type to be a child of another post type. In one function I am looping through those child posts, and I want to update the database to ...
0
votes
0answers
14 views

Sending Messages Back to the Template After Processing?

Is there an "offical" way to send a message back to the template after processing a form using add_action('admin_post') or similar for client-side feedback ? I was thinking of using the $_SESSION but ...
-3
votes
1answer
20 views

How can I fix my pagination?

I'm trying to get pagination working on my custom wp_query post loop. I currently have it set up, but when I click on page 2, it shows the exact same posts from page 1. I have a total of about 8 posts ...
0
votes
0answers
74 views

Change MySQL PDO connection to a WPDB connection

I have an autofill search box with a PHP script that gets data from the DB. It uses a PDO connection, and it works perfectly even with my WordPress Database, but since I'm not sure of how PDO works, I'...
-1
votes
0answers
46 views

Benefits of Using Wordpress Methods over Straight SQL Queries

I am building a "wrapper" front-end for Wordpress. My thoughts were that simply using PDO to run all queries would make the processing much much faster. Of course what this means is that I miss out ...
0
votes
1answer
28 views

add_action is never fired in child theme function.php

I'm setting up a child theme in WordPress and I can't make add_action to be fired within functions.php. Functions.php is called and I can run code from within. Any idea on what I'm doing wrong? $...
0
votes
1answer
490 views

How can I customize the size of the header of my theme?

I want to change the size of my header using the Sparkling theme. In functions.php, right below this: /** * Implement the Custom Header feature. */ I added this: add_theme_support( 'custom-...
3
votes
2answers
7k views

Using wp_get_nav_menu_items() to list children of children pages

I'm working with a Genesis Based Theme and I'd like build a Page/ Child Page menu structure. That part I can do with the help of some code produced by Bill Erickson. Essentially what I'm trying to do ...
-2
votes
0answers
17 views

How to erase a theme FOOTER | promo part?

I would like to erase the first line of my footer but I csn't do it with simple edits plugin. Do I have to modify my function.php file then ? If yes, what do I remove from it ? Thanks !
0
votes
0answers
15 views

Inserting jQuery into a custom page

I have made a custom front page, code below. <?php /* Template Name: Front Page Custom */ ?> <?php get_header(); ?> <body class="custom-front-page"> <div id="cfp-...
0
votes
1answer
713 views

Add custom fields after post/page title

I am using the Headway theme, and I need to add custom field code to page & posttitles. This is what I need to be able to do. [edit:image has been deleted] The red button will be added through ...
0
votes
1answer
444 views

echo value from 'select' field type into page template using cmb2?

I'm using CMB2 plugin to add metaboxes into a custom post type. I'm adding the additional metaboxes via functions.php onto child theme. It may worth to mention that parent theme/custom post already ...
0
votes
0answers
16 views

Add alt text to image posts using XML-RPC/functions.php

I am using the following part of code to upload images using xmlrpc: $content = array( 'name' => $title.".".$ext, 'type' => $type, 'bits' => new ...
0
votes
1answer
20 views

Copy custom field value to post title

I used the code found here. However, that does not update the title field until you open the post and hit Update button both via the back and front-end. I tried changing "save-post" hook with "...
0
votes
1answer
536 views

Change custom post type slug from plugin options

I'd like to give users the option to change a custom post type slug in my plugin. Using this answer, I'm able to hardcode it into a function: Redeclare/Change Slug of a Plugin's Custom Post Type ...
0
votes
1answer
26 views

How can I return the result of my custom function?

I have used the following source code to add an extra city field to my WordPress comment form: <?php /* Plugin Name: Comment meta data test Version: 1.0 Plugin URI: http://wpengineer.com ...
0
votes
0answers
45 views

Custom Function on Child Theme

I am trying to overwrite a function on Listable theme but it is not working complete. Here is the theme function function listable_wrap_the_listings( $html ) { $output = ''; $show_map = ...
0
votes
0answers
21 views

Pass Variable from Function to Shortcode

I realize that this may be as much of a PHP issue as a WP issue, but I'm posting it here because it does pertain to shortcodes and have some WP-specific functions mentioned. Basically, What I'm ...
3
votes
1answer
161 views

Should the value of core functions be escaped before outputting?

Should the value of functions such as the_permalink() be escaped before outputting to the browser? For example, do I need to escape the following? <a href="<?php the_permalink(); ?>">Link ...
0
votes
1answer
19 views

Warning: Invalid argument supplied for foreach() in post.php

Just moved my site to another server and now I get this error: Warning: Invalid argument supplied for foreach() in /home/menta/domains/land.menta4u.co.il/wp-includes/post.php on line 1172 On ...
0
votes
2answers
529 views

Passing variable as add_shortcode argument

I'm trying to pass a variable into the add_shortcode function to be used as the shortcode name but it does not seem to be working. Is there a way that I can pass a variable similar to this? foreach (...
-1
votes
1answer
31 views

How to string lines from the_content() hook in WordPress?

Inside my content-video.php template, I have the following codes: <iframe src="<?php echo get_the_content(); ?>" width="960" height="540" frameborder="0" allowfullscreen="allowfullscreen">...
3
votes
1answer
61 views

How to preserve PHP modifications while upgrading WordPress?

I made a lot of custom modifications in the PHP code of my WordPress blog. Namely in: archive.php, blog.php, footer.php, functions.php, header.php, search.php To provide customized search results, ...
0
votes
1answer
792 views

Load post attached images on a single page site with fancybox

I'm trying to make a single page site that will display posts as thumbnails in some part. Then if a thumbnail is clicked, I want all the images contained in this post to be loaded with fancybox while ...
0
votes
0answers
14 views

Hide pages + widget edit

I have 2 questions on this site i have this item i was wondering how can I make this item not show in the widget area or any other part of the site but still be accessible if some1 has the link to it ...
0
votes
1answer
44 views

Ajax not working to insert, query and result data

On my site, through a form I send/register same information in database, do a SELECT/query and return it! Return the last table saved in database, just that user just entered on the form (along with ...
1
vote
1answer
950 views

Remove Header and Footer in iframe

Many people embed my website's pages in their websites as iframes. I want them to don't take my footer, header and a specific division in those iframes. Since, footer, header and mentioned specific ...
0
votes
1answer
15 views

Custom post type in Custom widget - $listItem

Hi i have a slight problem when making a custom post type widget. the problem is that when i add a custom field in the code the part that shows the custom field information get's on top of the output ...
0
votes
1answer
15 views

ACF in wordpress

Hi i have a slight problem when making a custom post type widget. The problem is that when i want to get the field i want to use in a inline style it doesn't work. This is my code: class ...
-1
votes
0answers
19 views

How to hook for disabling sending processing order email notification if order total value is 0 - Woocommerce?

I need to disable woocommerce sending processing order email notification if order total value is 0. I also tried: : add_action( 'woocommerce_email', 'unhook_those_pesky_emails' ); function ...
-3
votes
0answers
28 views

error in a php snippet: is_checkout() [closed]

I am seeing a new error in a snippet I've been using successfully (until recently). Something in this line is off... if ( ! is_checkout() || ( is_checkout() && WC()->cart->...
0
votes
1answer
41 views

Shortcode to eliminate <p> and replace </p> with <br>

I have a filter that removes opening p tags and replaces closing p tags with a br tag sitewide. The client would like this filter in a shortcode that they can use only on specific portions of the site....
5
votes
2answers
8k views

Add custom template page programmatically

I'm trying to add template page from a plugin,and my template page is in this plugin folder.Is this posible?Here is my code: global $user_ID; $new_post = array( 'post_title' => 'Test ...
0
votes
1answer
2k views

Let users upload image(s) to the post from front end

I want to enable logged in users (Wordpress) to submit posts from front end (among with other data). My form is working great, I add custom post meta data which I later display on custom post page. ...
0
votes
0answers
9 views

Get a color name from any RGB combination (script included) [migrated]

i am returning a hex and an RGB color in my app (from camara) and i want to use a script to identify that color and display a name... ive found http://gauth.fr/2011/09/get-a-color-name-from-any-rgb-...
0
votes
1answer
17 views

No compression occurs on my jpegs after adding jpeg_quality hook to my functions.php file

I'm attempting to perform some basic jpeg compression by using the jpeg_quality hook inside my functions.php file but there is no compression/resizing taking place. I'm only measuring file compression ...
-2
votes
0answers
27 views

Using external function() from functions.php

Does anyone know how to use a function() which is written in a plugin file... I want to call this function() from theme's functions.php.
0
votes
2answers
427 views

Use Exact Image Size using add_image_size

I have a pretty basic question. It may be very noob question, but it is bothering me a lot. In my theme I've added a custom image size like this: function img_update() { if ( function_exists( '...
0
votes
2answers
557 views

Possible to register multiple custom taxonomies in one function?

I'm registering 7 custom taxonomies in my functions.php. Since each function uses the same labels and arguments and is attached to the same Custom Post Type, I'm wondering if it's possible to register ...
-1
votes
0answers
16 views

How can I echo the latest time a Product was updated (Woocommerce)? [on hold]

I would like to print out when the product was last updated, as I sell online courses. Any idea on how to implement this as a shortcode?
0
votes
2answers
682 views

Show the post date using the wp_get_archives() function?

I have some doubt about the wp_get_archives() function In my website I have create the following page template that use the wp_get_archives() function to show the posts list: <?php /** ...
0
votes
1answer
21 views

Issues separating my Plugin pages into different files

As my last (first) plugin got a bit hard to manage with 6 admin pages in 1 file, I decided to split them up for this one, but I am getting nothing but issues doing so. In my plugins functions file (...
0
votes
0answers
14 views

How to call a function declared in post.php

I have created a function which checks the post meta data of the post and then chooses a particular category for the post. The function is working fine. I have declared it inside post.php. I want this ...