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

Functions.php file in a custom child theme messed up without backup

I just ran into some problem. I'm a beginning Wordpress dev. I don't know much and I have messed up my functions.php file. Here's how it happened: I copied the code from This site. This was supposed ...
-1
votes
1answer
34 views

Remove Disqus JavaScript from homepage

Hey WordPress friends, I’m using the Disqus comment system plugin, which is working fine. My homepage is just a collection if recent posts and therefore not having the option to leave a comment (as ...
0
votes
1answer
12 views

Both the require and add_template_part function are not including the file

I'm trying to add a require function in my functions.php, to include a file that is in the wp-content folder. I first tried this with the function content_url . 'filename.php'So the line of code ...
0
votes
1answer
29 views

Autogenerate a Table of Contents

I am trying to generate a Table of Contents at the top of each of my posts and would like to minimize the requirements on the author. Ideally, the author would enter only various levels of the header ...
0
votes
0answers
24 views

I have problem when use antispambot for other languages

I have Issue about " antispambot() " when I enter German language like "höhen@yahoo.com" , it's return incorect characters . I know this function encode email address but It's work fine just for ...
-1
votes
0answers
16 views

Change category link. Lead it to a specific page

How can I change a link of any shop category in functions.php? I have 4 shop categories. To one of them I need change its href-link, it should go to specific shop page. How can I approach this?
0
votes
1answer
22 views

How do I integrate my Child Theme into a Custom Template?

I started working on this yesterday, and while I was able to successfully load my child theme, some of the site functionality went haywire. I suspect that I may need to add some code to my functions....
-2
votes
0answers
24 views

How much PHP one Needs to Build a Professional WP Plugin - Basis WP Knowledge and a PHP assistant will help me to Build One Such Professional Plugin? [closed]

I started only sometimes back to learn wordpress. Sometimes I feel that WordPress is too vast, but sometimes I feel that its coding practice can be mastered within 2-4 months. When I say that its ...
0
votes
1answer
19 views

Using wp_localize_script in template file - is it secure?

I have the following code inside one of my template files (NOT functions.php) $datatoBePassed = array( 'pageTitle' => get_the_title() ); wp_localize_script( 'main-js', '...
0
votes
0answers
9 views

Class For Dependent Child Post Data using get_posts()

I want to use a class to display various parts of a dependent post via a class. This is my first stab into OOP, so please be try to be somewhat gentle, if possible. :) At a high-level I have a two ...
-3
votes
0answers
16 views

how to use download links with CONTACT FORM 7?

I want to allow user to download my PDF only after they filed their email id. On every post there is a different PDF to download. I am saving these download links in custom fields of WordPress ...
-2
votes
0answers
21 views

How can I disable author and hide their posts?

I want to disbale authors and after that they gonna be hide such as their posts, media and etc. also on the contrary of above , when i active authors their posts display to every one Any idea?
-3
votes
0answers
17 views

OOP help, how to implement custom lookup in my associative array within functions.php

I'm writing a function to execute on a custom action: //############## START OF NON WORKING CODE add_action( 'gform_pre_submission_1', 'myCustomFunction' ); function myCustomFunction( $form ...
0
votes
2answers
36 views

How to know if user logged in

I have PHP code <?php if ($_SESSION['logged_in'] == 1) { echo '<script type="text/javascript">var logged_in=true;</script>'; } else { echo '<script type="text/javascript">...
0
votes
0answers
19 views

Hide Archives From Past Year in Sidebar (Twentysixteen)

Following the instructions on this page I was able to limit the archive list on the front page of my WordPress site to the last 3 years. However, when I go to individual post pages, the full archive ...
0
votes
0answers
21 views

Generate and return a PDF file in functions.php

We have the following process flow: 1.) Users fills in a form (name and surname) 2.) Backend php scripts look for the record in local CSV files 3.) If record exists we would like to return the data ...
-1
votes
1answer
36 views

How do grab the main loop, with conditions, and output via shortcodes

I don't have any code for this because I'm not sure how to begin. I created a category called "News". On my homepage I want to show the 3 most recent articles, but I need to output them using a ...
0
votes
1answer
46 views

How to add attributes to a shortcode

Reading the codex, I have: function btn_shortcode( $atts, $content = null ) { $a = shortcode_atts( array( 'class' => 'button', ), $atts ); return '<a class="' . esc_attr($a[...
0
votes
1answer
30 views

Every time I use wp_get_current_user() my plugin breaks

I have been trying to make a sign-out plugin that allows users to sign out from military training activities that they should be at. After they fill out a form explaining why they are not going to be ...
-3
votes
0answers
32 views

Create like button from scratch

Would someone kindly give me a pointer on direction to take to create a simple test data unique to each user that can be updated by other user from front end and saved in database. I know it sounds ...
0
votes
0answers
15 views

How to use $prev_url and $next_url to display posts only out of a specific category

Struggling with a function used to display a previous and next button on a single portfolio page. I have set two pages up with display of a portfolio. Each page displays a portfolio with a unique ...
0
votes
1answer
37 views

Redirects based on a JSON file

Having a JSON file, how can we set up WordPress to redirect the urls (if it's found in the JSON file)? For example: { "foo": "bar", "foo-1": "baz" } Then /foo will redirect to /bar and /foo-1 ...
0
votes
0answers
25 views

Passing dynamic local variables without using class

I creating functions in my function.php and I have a question regarding passing local variables between functions if the variable is a dynamic one that changes according to certain conditions. Let ...
1
vote
0answers
18 views

Pass updated local variable between functions? [duplicate]

I creating functions in my function.php and I have a question regarding passing local variables between functions. Let say I have the functions below, A and B, and I have the variable $amount. Now ...
0
votes
0answers
29 views

How to create a global variable in a plugin to use in another plugin

I have a variable in a plugin that stores values ​​to her being fired, these values ​​are entered in the [post_title] but before that he a variable of $post_title_template name plugin and would like ...
-3
votes
0answers
15 views

Auto refresh the page when time expires [Plugin: Launcher: Coming Soon & Maintenance Mode] [closed]

I am currently using Launcher: Coming Soon & Maintenance Mode plugin to display a coming soon message with countdown timer to specific date and time when the site gets launched in-front of all the ...
0
votes
1answer
23 views

Help With Creating Shortcode

I'm looking for a way to check just check for an option existing when executing a shortcode, but that option doesnt need a value. How do I just check for JUST an option? For example I tried this out, ...
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. ...
3
votes
2answers
116 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="...
-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 ...
-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 ...
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 ...
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 ...
-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. ...
0
votes
1answer
86 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
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
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
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 ...
-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
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 ...
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
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 ...
-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 ...
-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 ...
1
vote
1answer
43 views

Reuse variable in hook callback

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? $...