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

Adding a section in line at the end of the main navigation menu in php

I'm working on a wordpress site where I'm trying to get the "Members" login/logout link & widget area inserted into the actual end of my front-end-nav-menu instead of after, as it's currently ...
3
votes
2answers
115 views

How to change the markup Wordpress inserts for post images

I am developing a theme with Underscores for WordPress. When the user adds an image using the TinyMCE editor the following code is inserted: <img class="wp-image-45 size-full aligncenter" src="...
0
votes
0answers
16 views

Getting custom image size URL in functions

I am trying to load preload-thumb into data-pil-thumb-url within the functions.php file so when a user edits a post with the TineyMCE it is automatically wrapped in a figure with the right classes. ...
1
vote
1answer
507 views

Current path on page in functions.php

How can I get the current path of my page? I know how to do it inside a template file, but I need it inside functions.php. And it has to be before the send_headers hook, because I'll use this info to ...
0
votes
2answers
485 views

Adding and updating repeating custom field meta data

I've got 20+ hours into this and could really use some help. Here is what I am trying to do.. For each record, add post meta. If the post meta already exists, update each field in the array. Just like ...
0
votes
1answer
3k views

Visual Composer creating own shortcodes with vc_map() to return simple Image

I am using the Plugin Visual Composer with in a new Theme I develop. My question is about mapping shortcodes to Visual Composer arrays. The problem I get, when I try to make a custom element for an ...
-1
votes
0answers
27 views

Email verification function inside ajax registration pop up

I have created a registration popup form following this tutorial and its working. Also installed woocommerce user email verification for sending verification email to newly registered user. When i ...
-1
votes
0answers
18 views

unzip file/folder in wordpress using command

create a folder and put this code and save with .php $unzip = shell_exec("unzip file-name.zip");//file-name is your zip file name echo 'Unzip command executed'; Copy your zip folder where your this ...
0
votes
0answers
3 views

is it possible to pass a multidimensional array via declaring it in a function? better just to declare it global? [migrated]

good afternoon, i've been trying to figure out build an array for use in multiple functions, inside functions.php. it appears that i need to create the array in its own function, and then refer to it ...
0
votes
0answers
15 views

Use Shortcode to pull specific custom post type into any page

I'm looking for a way to code a shortcode like [shortcode slug="slug-name"] that will pull data from the slugs specific custom post type and fill the variables of my template that I'm attaching or ...
-1
votes
1answer
21 views

Load a Header in wordpress

I'm trying to added upload header in Wordpress but not upload the image but it print out the link of the header. How do I fix the problem the him have with wordpress. <?php if ( get_header_image()...
-1
votes
0answers
23 views

WooCommerce Shop Page Display Product Div as a Weird Loop

function neato() { global $product; if ( $product->get_permalink() ) { echo '<script src="https://code.jquery.com/jquery-1.10.2.js"></script><div class="new-projects"></div> ...
1
vote
2answers
41 views

When 'is_post_type_archive()' return true?

I visit archive page link http://src.wordpress-develop.dev/2016/ or http://src.wordpress-develop.dev/category/Markup/, on either page is_post_type_archive() return false. I have added ...
0
votes
0answers
26 views

Limit Number of Posts on Blog Category Page Throwing 404 Error on Paginated Pages

Using this code in the functions.php file to limit the number of results on Search pages and Blog Category pages, yet when viewing /page/2/ etc. for the Blog Category pages, they are throwing a 404. ...
2
votes
2answers
905 views

Using plugin functionality in external php script not working

I am encountering a strange problem which I couldn't solve so far. I'm calling a .php script via cronjob (Debian/GNU Linux). To use wordpress functionailty I added: define('WP_USE_THEMES', false); ...
0
votes
1answer
85 views

Add Adsense code between job listings - wp job manager plugin

I am using the wp-job-manager plugin and i want to add an Adsense code between the job listings ( after fifth job listing ) in the page with [jobs] shortcode. The function that outputs the jobs ...
0
votes
0answers
3k views

Send post id through ajax and get the post content back

First of all i want to say that I am a WordPress beginner :). I am trying to get a post content in a modal by using ajax. So i send the id through ajax, but i cannot execute the php code anywhere on ...
1
vote
1answer
84 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
19 views

Code to restrict view of post based on date of user registration versus post

How can I include a function in a theme that will display a different text than the text in the post if the user registration date is > post date?
-2
votes
0answers
44 views

Can't change woocomerce checkout field to optional

I am trying to change checkout field like address to be optional (I need it only for companies). Therefore, I am using following code: $fields['billing']['billing_address_1'] = array( '...
0
votes
2answers
22 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
16 views

Enqueue scripts in footer

I'm trying to build a plugin and enqueue my scripts to footer. For performance reasons I'd like to load this plugin scripts after the functions.php scripts, because furthermore it will break the page ...
0
votes
4answers
423 views

Is it legal to redefine wp_password_change_notification in a mu plugin?

I am trying to add some logic to this function of when to alert the admin to a password change but no email is being sent at all. The codex says it needs to be declared in a plugin, so is this legal ...
-2
votes
1answer
49 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 ...
0
votes
0answers
20 views

Can you update a post with content from a DIV?

I'm very new to PHP and am wondering if, within wordpress, I can create a function/action that will update a post_content with the data inside a div with a class="output-box"? I have found an example ...
3
votes
1answer
954 views

Remote upload file to server B

I'm aware this might be some of the hardest coding to do ever, but thought of giving it a try. Im basically trying to detect all (mp3) filetypes uploaded through the Wordpress media upload and send ...
1
vote
2answers
655 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 ...
0
votes
0answers
29 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 ...
6
votes
4answers
288 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 ...
-1
votes
0answers
45 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
16 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
23 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
97 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'...
0
votes
1answer
500 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 ...
-1
votes
0answers
21 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
724 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
509 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
24 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
33 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
540 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
28 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
31 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
164 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
30 views

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

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
558 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
32 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
82 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
798 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 ...