Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [functions]

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.

0
votes
0answers
11 views

How to upload 3 attachments to current post?

I have a form which updates a post but when updating I need to be able to also upload 3 posts: <div class="form-group"> <input class="form-control" type="file" tabindex="3" name="custom-...
0
votes
0answers
7 views

Load Disqus comments after clicking a button

I have an official Disqus plugin installed on my site. However, I would like to load the comments only after user clicks on a button - "Load comments" for example. Comments should remain hidden until ...
0
votes
0answers
11 views

Function not updating user_meta correctly when $current_time triggers

Hi all, I'm having trouble with my logic for the following function. I cant seem to make it work when it is supposed to, and how to override it when it is authorised to. The aim of the function is: -...
0
votes
0answers
19 views

Display avatar and username in html

Previously I used the following code in the functions of my theme. In the main menu I created an item called #profile_name# and the username of the connected member was displayed. add_shortcode('...
-2
votes
0answers
20 views

Webmail not working in Gmail [on hold]

I have connected my webmail server to Gmail so that any email come to my Cpanel webmail will directly transfer to Gmail. Recently i have uploaded my website to Cloudflare. After uploading, my webmail ...
0
votes
1answer
13 views

locking content with overlay/pop up ads

how can i add a pop up before content or before downloading files ?i want to show a custom ad pop up (with option to close ad-similar to what you see in ad.fly url shortener) before a file download /...
0
votes
1answer
25 views

wordpress function for trending now posts

There are many websites that have trending now widgets of sections on the website that shows the trending blog posts currently on the website which are blog posts that are currently being requested ...
0
votes
0answers
7 views

Menu to the right of screen on desktop using Bootstrap 4

I'm fairly new to WordPress development and would love to learn as much as possible. I am building a theme from scratch and using the wp-bootstrap-navwalker (https://github.com/wp-bootstrap/wp-...
4
votes
2answers
195 views

What’s the difference between esc_html, esc_attr, esc_html_e, and so on?

I got feedback from security guy and he pointed out that I should use proper escaping of user input in my code. So I've done some research and found escaping functions. What’s the difference between ...
1
vote
1answer
19 views

Members only site - still need the lost password page accessible

My site requires login before viewing any page and it works great: function wpse_131562_redirect() { if ( !is_user_logged_in() ) {auth_redirect(); }} add_action('template_redirect', '...
2
votes
0answers
53 views

Override woocommerce wc-class function

I'm not good in WP and plugins and will need some help here. I've read that is possible to alter some WC core function with filters and action but probably I didn't understand this correctly. I want ...
0
votes
1answer
18 views

Detect what link user clicks and Redirect to a specific page for logged in users only

I have a link in my WP website Account link. I would like this to work normally for logged out users. However for Logged-in users i would like this link to take them to another page url. I have tried:...
0
votes
0answers
21 views

“Conditional query tags do not work before the query is run. Before > then, they always return false. ”

I'm getting the following error Notice: is_tax was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging ...
0
votes
1answer
29 views

WP_Query To Display Product Of Brand On Taxonomy Page

I am trying to print all products of a brand on a taxonomy page. I find the wp_querry but i cant print the current brand name of the brand to show all products in this page. What to put on terms ...
0
votes
1answer
20 views

Post source link plugin - small modification

I'm using a little plugin that allows me to add source link to every article. I found the code in this thread: Article source link for posts It's almost perfect, but I need to make 2 little ...
0
votes
0answers
34 views

enqueue script adds another .css with same name?

First I apologize if I'm not clear but I'll try to explain my problem with my enqueue script. I am trying to build a WP theme (conveting HTML & CSS Website) with existing files, but when I try to ...
0
votes
1answer
34 views

How to use `foreach()` in ajax call

I have written a code for retrieving data from the database using the ajax for WordPress. The following code is the one written in the functions.php. The code is for getting the id and names of ...
0
votes
1answer
20 views

Change 'Categories' to 'Topics'

I'm trying to find a way of displaying 'Topics' rather than 'Categories' and so far not being very successful. I tried this: function translate_category($translated) { $translated = str_ireplace('...
1
vote
1answer
20 views

'is' functions and 'get_query_var' not working

Why does is functions not work inside an Ajax function? Except for is_user_logged_in? I also tried using get_query_var and it did not work. jQuery: jQuery('.post-modal').live('click', function(e) { ...
1
vote
1answer
18 views

Max file size not updating

Hi I am a beginner at WordPress and am currently trying to increase my file upload size. So far I've tried two ways: The first way was to add this to the bottom of the functions.php file: @ini_set( ...
0
votes
0answers
10 views

Woocommerce Add custom “Add to cart button” in single page with tags

I want to add a custom "ADD TO CART" button in the single product page. I have done it using the id of the product. <?php echo '<a href="?add-to-cart='.get_the_id($product_id).'">ADD TO ...
0
votes
2answers
29 views

Setting a cookie upon specific URL visit

I'm trying to set up, when a specific page/url is visited that a cookie is set and saved. So far I've tried this: add_action('init', 'set_cookie', 1); function set_cookie(){ if ( $currentURL == '...
0
votes
0answers
22 views

Remove action hook from Class, understanding OOP

I am trying to remove an action that is within a class, of the parent theme. I made an example of the code I have, below. I am trying to remove the action in the child theme functions.php. I've tried ...
0
votes
1answer
18 views

WP_CRON issue with UTC and local time

I have made a plugin to change some user metadata on a schedule according to the wp_cron function. If the current time is say between their lunch hours (that is in their user profile as date('g:i a', ...
1
vote
2answers
60 views

Checking is user author of number of posts?

I have this function... $user = wp_get_current_user(); if (( in_category('Locked') ) && in_array( 'subscriber', (array) $user->roles ) ) { /* Is subscriber, is in category Locked, has ...
1
vote
2answers
133 views

Proper way of using functions in action hook?

I am wondering if the below logic is correct and if certain circumstances should be present for it to work, since in some cases it does not seem to be working. The example below is quite simple. Let'...
0
votes
0answers
16 views

Offset with ajax load more posts duplicates

I have a shortcode that gets posts. I am using the shortcode three times on the page. The first time I grab the first 6 posts, the second time I offset by 6 and grab the next 4 posts, the third time I ...
0
votes
0answers
26 views

CSS disabled after getting rid of emoji

I created custom theme in Wordpress and wanted to apply it to my site. Apparently, in the header section, besides the elements, weird text about emoji appeared. I found out that I have to turn out the ...
1
vote
1answer
40 views

How do I use <picture> element instead of <img> tags in WordPress post content having webP support?

I am developing my custom theme and trying to figure out how to modify the default code for WordPress image inserted into the post content, so I could add support for webP format and have it within &...
-1
votes
0answers
11 views

Alter viewport values

I need to alter the viewport values with my child-theme. At the moment there is <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> but i need to ...
0
votes
0answers
15 views

I need to change code in plugin admin file with using another plugin don't touch main plugin

I need to change this code // wildcard postcode ? $wildcard_position = strpos( $rate_postcode, '*' ); // The rate has a wildcard match only the beginning of both if ( $wildcard_position ...
0
votes
1answer
20 views

Is admin section completely customizable in terms of styling?

Can we completely customize the WordPress dashboard in terms of appearance and style? I have uploaded the image: Or Wordpress doesn't allow such conversions. I mean the right-hand side part shown ...
0
votes
1answer
15 views

Auto copy value from specific user meta field to another field

I'm looking for synchronizing specific user meta field with another one. ex: Coping user phone number to woocommerce billing phone. So the admin can only edit one field and the other updates ...
0
votes
1answer
21 views

Wordpress 302 Redirect to Random Product/Post/Page

I'm trying to add the ability to redirect a user to a random product/page/post url similar to example.com/page/random which would redirect to example.com/page/oneofmany. This question is not ...
0
votes
1answer
8 views

How to get correct value from checked()?

I am trying to create 2 raido buttons as a category custom field, and in function.php I do: $feat = get_term_meta( $tag->term_id, '_feat', true ); <input name="feat" type="radio" value="0" &...
0
votes
0answers
10 views

How can I get postal using GeoIP?

WooCommerce: 3.5.1 WordPress: 4.9.8 GeoIP Detection plugin 2.9.1 https://ru.wordpress.org/plugins/geoip-detect/ I need to set the postal code value from GeoIP into billing or shipping fields in ...
0
votes
1answer
17 views

How can I pass a shortcode value to the head in wordpress functions.php

I'm trying to create a shortcode for charts on wordpress posts. So far I've got the shortcode working and I can see the shortcode values are being passed through, but what I need to know is how to ...
0
votes
0answers
10 views

Add button or functions to column in table from csv file import

I publish in a site information received from a .csv file as a table with a plugin of type wpDataTables or Table Generator with for example the following information in the following form: "Job Name" "...
0
votes
0answers
39 views

How to override parent function $title in child theme

I made a child theme and want to override some text produced by a function but i am not sure how to do it or where to put the code in my child theme directory. Original: $title = __('Recent Posts', '...
0
votes
0answers
15 views

Add Cart Item meta data based on other items

I use the following function to show the discount in the cart if a product in the cart is on sale: function my_custom_show_sale_price_at_cart( $old_display, $cart_item, $cart_item_key ) { /** @...
0
votes
3answers
24 views

static array on functions.php

In functions.php, I want to access the DB once to get an ACF object, and then "save" it locally to prevent further requests to the DB. I thought of first calling the following function in the "init' ...
0
votes
2answers
24 views

Cant display an image via PHP in wordpress

I have a strange problem, when I try to enter the source of an image tag using PHP it shows me the following error in the inspector <img src=(unknown) alt=""> this code fragment gives me the ...
0
votes
0answers
12 views

Create a WordPress menu with many levels without using the walker class or wp_nav_menu from scratch

SPOILER: it works nicely only if you have a two levels menu Here's my problem. My goal is to build a Wordpress menu from scratch, without the support of the walker class or the classic WordPress menu....
0
votes
0answers
9 views

Create a default parents for children pages that have the same parent in the menu

Here's my problem: I'm building a website and my goal is to create a nice menu that will interact with the pages. So far so good, except for one problem. The structure of my menu is something like ...
0
votes
0answers
19 views

multilingual functions.php

Could someone please help to make a piece of a themes funtions.php multilingual. I've made some changes for Dutch in the title and placeholders cause they were in English, but it stays Dutch when page ...
0
votes
0answers
16 views

Ajax Cross-sell optional extras below single product description

Screenshot below isn't Woocommerce, but id like to replicate the functionality of the "optional extras". What is the best way to accomplish this? Having a list form of "cross sell" products under ...
0
votes
3answers
63 views

How do I create a child theme from PowerMag theme

I am using PowerMag 2.5 as parent and can't seem to find a way to get a working child theme. As far as I am now, I can only extend css in the style.css but as far as overriding, nothing has worked. ...
0
votes
0answers
24 views

Pagination in shortcode not working

I got a shortcode that displays a loop of posts with pagination. My problem is I can seem to make the pagination work. Although the URL changes but the list of the page is not working. function ...
0
votes
3answers
47 views

Adding Gravity Form With if(is_page) Is Not Working

Please bear with me as I am a front-end developer trying to grapple with PHP. I am attempting to add a gravity form to specific pages on my website website by adding a function to my functions.php ...
1
vote
3answers
41 views

How can I change the do_action function in footer (copyright area)

Theme: Education LMS How can I remove the theme information from my footer copyright area, or how can I edit the do_action function? So that only display what I want to display in footer. ...