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.

1,667 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0 votes
0 answers
92 views

Save_post - Warning: Cannot modify header information

I'm trying to populate an ACF field on save (updating or creating the post) while running a geolocate function using mapbox. I'm getting a cannot modify header information error when hitting the ...
user3330820's user avatar
0 votes
0 answers
96 views

adding dynamic/multiple slug values in 'option_none_value'

I am working on a wordpress website and i am little stuck into one situation, what i want is that to add multiple and dynamic slug values from job listing taxonomy, right now i have to manually insert ...
Jain's user avatar
  • 29
0 votes
1 answer
282 views

Get parent category name when only child category is applied to a product

I'm trying to get the parent category of a product when actually it's assigned to a child category of the parent, but not the parent itself. The function below works when I assign both the child and ...
Korla's user avatar
  • 1
0 votes
2 answers
57 views

Find most used words in post titles

Is there any technical way to search post titles and return the results of the most used duplicated words in them? I.e Three articles in total: The quick brown fox jumps over the lazy dog A brown bag ...
JohnnyBratsoni's user avatar
0 votes
0 answers
101 views

Wordpress Sticky Post Count "Fix" Breaking Pagecount by 72 pages!

I have a permanent sticky post on my front page and have implemented the code (pasted below) into my functions.php file to stop it adding an extra post to my post count on the front page (it's a grid ...
Jason's user avatar
  • 13
0 votes
1 answer
326 views

Default excerpt for parent of a custom post type

I've created a hierarchical post type called mycustomposttype. Parents are created in the backend, children via gravityforms. Due to my theme setup, I would like all parents in mycustomposttype to ...
dkrahl's user avatar
  • 1
0 votes
1 answer
29 views

Show sidebar only to author of post

I am trying to show the sidebar only if the user viewing the post is the author of that post. So anyone else viewing the post, if they are not the author, then they cannot see the sidebar. So if "...
orange-oc's user avatar
0 votes
0 answers
449 views

$post->post_content empty while all other properties are correct

I'm trying to pull raw post content in order to identify if a particular shortcode is used, and if so, what its properties are. All of the properties of my $post object return what I expect except ...
GoetzOnline's user avatar
0 votes
1 answer
52 views

Sharing varible between two add_actions

I'd like to share a variable between two add_actions. Currently I'm trying to use a global. However it doesn't work. This simple example below illustrates the problem. In this example, ...
Scott Paterson's user avatar
0 votes
0 answers
13 views

Make visible page only in the trash

i'm working on a plugin that generate some pages and they are hidden to User in the wp admin. But i had not choise to do a radical action and hidden ALL pages created from my plugin. The ideal for me ...
diegod1os's user avatar
0 votes
0 answers
25 views

What is the earliest Hook a Script can use?

At present, I am disabling Right Click through the use of the following code: <?php // Disable Right Click function disable_right_click() { ?> <script> jQuery(document).ready(function(){ ...
Craig's user avatar
  • 358
0 votes
0 answers
36 views

removing description tabs - single product page - breaks footer

I would like to only dispaly the gallery & short despcription on the single product page. Using: add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); function ...
Anna Moors's user avatar
0 votes
1 answer
605 views

How do I trigger WP CLI DB export using a PHP function?

I want to use WP-CLI to export a database - using wp db export - to create backups. I also need to use cron to control the backup schedule. WP-CLI is installed on my managed host, and I can use it via ...
BlueDogRanch's user avatar
0 votes
1 answer
244 views

removing the standard dashboard widgets in WP so I Can replace with custom

The following code has removed some but not all of the widgets from the WP dashboard. I am adding it to my functions file inside my theme. My question is two fold: 1.) What about this is throwing the ...
Ted's user avatar
  • 33
0 votes
2 answers
532 views

Add Javascript code to functions.php childtheme

I would like to add the following JavaScript function to a wordpress child theme (functions.php). Unfortunately I am not able to make it. Function: $.fn.cityAutocomplete.transliterate = function (s) { ...
shotput_wp's user avatar
0 votes
1 answer
241 views

Populate acf-field, depending on block name

I have an acf select "global_fargtema" for all blocks what i am trying to do is, if a block name is == "acf/full-width-talker" populate the field "global_fargtema" with $...
Stefan Avramovic's user avatar
0 votes
0 answers
181 views

How to use WP conditional tag in a functions.php with OCEANWP Theme?

Theme - OceanWP Page Builder - Elementor Single Post templated created using Elementor I am trying to add custom code for the SINGLE BLOG POST. Using a conditional tag "is_single", I want to ...
Chipsy's user avatar
  • 33
0 votes
0 answers
378 views

Best practice to call a function from a button-link?

I am developing a WordPress website where I have to link a button to a function inside the functions.php file. Meaning that when someone clicks on a certain button, this will trigger a call to a ...
vsapountzis's user avatar
0 votes
1 answer
159 views

How to create algorithm for ordering posts in Wordpress?

I have a news feed in my website where all the blog posts are displayed. Wordpress default is to dislay these in order "latest first". Using Elementor and Likebtn I have learned how to order ...
raen's user avatar
  • 1
0 votes
2 answers
734 views

Gravity Forms: How to add PHP function to confirmation conditional shortcode?

In Gravity Forms, I have a confirmation set up with various conditional shortcodes. Example: [gravityforms action="conditional" merge_tag="{:3:value}" condition="contains"...
Michael's user avatar
  • 281
0 votes
1 answer
21 views

Disable wordpress update notification

i need a code to paste in my wordpress theme function for disable wordpress update notification. https://prnt.sc/tyigt3
Vincenzo Piromalli's user avatar
0 votes
0 answers
81 views

How to change this ajax function to submit to the default wordpress content area instead of the custom field 'seller notes'?

I am stuck editing this form submission. When a user fills out the form, I want to map the 'stm_seller_notes' to the default wordpress content area. There are two problems I am trying to solve, stop ...
Aran Joyce's user avatar
0 votes
1 answer
35 views

wpdb->query returns different value to phpMyAdmin

I am trying to build a shortcode that will query a db and sum. Here is what I have so far: function my_plugin_name_count_people() { global $wpdb; return $wpdb->query ("SELECT COALESCE(SUM(`...
Bob's user avatar
  • 13
0 votes
1 answer
25 views

Submitting form to PHP

I am submitting a form to PHP edit post metadata. The logic I built is having multiple "ifisset" to execute different parts of the requirements based on the inputs. There are 4 issets, the ...
Ali Hamdan's user avatar
0 votes
1 answer
217 views

Remove span tags from WooCommerce Downloads page

Hello i have problem with my woocommerce downloads section in "my account" page - span tags between product name and variation name. https://i.stack.imgur.com/TIg0X.png I tried to make a ...
Kuroi Ryuu's user avatar
0 votes
1 answer
21 views

ACF Fields are not showing up on Homepage

I want to Customize the Yith Plugin for which I want to add some custom fields with Existing fields. I am getting fields from ACF and adding them to an array ACF Fields are showing up in Yith Setting ...
Sheeraz Ahmed's user avatar
0 votes
0 answers
81 views

How Can I Create a Friendly Slug for a Dynamic Page?

I built a dynamic page template that pulls biography information from a MySQL table. The page works fine but the URL is ugly. Officer-Biography/?ID=1 I have a set of canonical slugs that I want to use ...
jpollar's user avatar
  • 13
0 votes
1 answer
111 views

Adding discount functionality to the cart

Hey guys :) I'm trying to implement a custom discount rule to the cart. Basically there is WooCommerce and the site is selling t-shirts. There is a current promotion that if you buy 3 t-shirts, you ...
tsvetko.krastev's user avatar
0 votes
0 answers
153 views

How can i avoid duplicate same post in wp?

I m working on a wp plugin and i have 3 tables. In my plugin i have two different loop: both of them create programmatically a page from my tables. My problem is that if i refresh the page, it ...
Zed93's user avatar
  • 1
0 votes
1 answer
98 views

Custom attachment function not working in v5.4.2?

I have a function that I re-use in a number of custom themes when required to fulfil a customers need. I understand this can be achieved now with repeaters in ACF Pro but as I had a working function, ...
Ash_Flourish's user avatar
0 votes
1 answer
1k views

Get custom field value from the function.php

I need to have the value of a custom field in the functions.php file. This what I already have. I can get the value on a page template, but in this case it is need in the functions.php file because I ...
Dennis's user avatar
  • 135
0 votes
0 answers
206 views

Google Analytics - add script to functions.php

I want to connect google analytics to my site. I don't want to do it through the MonsterInsights plug-in. I added this script to functions.php. Will it work? <?php /** * Add functions files * * @...
Szachmat's user avatar
0 votes
1 answer
160 views

How to move a post from one category to another

I am new to PHP. Please help me to achieve the below scenario. I am trying to achieve this from the last 3 days. I've two categories in my WordPress dashboard named "Available (id:3)" and &...
sajeergraphix's user avatar
0 votes
0 answers
396 views

custom error message for empty username and password using authenticate filter not working

I'm trying to override the authenticate to edit the default error message. /** Purposed: Custom Login Error Message Description: This function override the default error message on login form. **/ ...
Polar's user avatar
  • 131
0 votes
0 answers
75 views

Class parameter in get_avatar args doesn't get added to output

I try to add custom class on get avatar in comment walker get_avatar( $comment, $args['avatar_size'], '', '', array('class' => 'myclass') ); But class doesn’t show in source code. Thx Edit : ...
David Sticker's user avatar
0 votes
1 answer
2k views

WP Ajax Function Always Returning undefined

What is the deal here? JS FUNCTION 'custom.js' function validate() { var email = jQuery("#billingemail").val(); if (isValidEmailAddress(email)) { jQuery.ajax({ ...
Brian Bruman's user avatar
0 votes
0 answers
35 views

Deleting guests profile users after 1.5 hours

I need to automatically delete the users that are subscribed through a wpforms after 90 minutes of being created. Users created this way are marked as "invitados" on the profile. I found ...
Victor Vazquez's user avatar
0 votes
1 answer
27 views

Remove check boxes and its label from screen option for custom role

I want to hide many check boxes and its label in screen option only for custom user role (wdm_instructor and group_leader). How to apply below code so its for custom user role only: add_action( '...
jasaweb's user avatar
  • 51
0 votes
0 answers
255 views

Best way to use variables in multiple functions?

So I am running into issues in Query Monitor - duplicate queries. The reason being that I have functions that need to get say, a customer's order status or the like. What is the cleanest, correct way ...
Colin G's user avatar
0 votes
0 answers
153 views

Child theme overirde template-tags in a theme built on underscores in inc/template-tags

I've read this post and I don't think this question is a duplicate because I have a specific question that has not been answered. My parent theme is using the following to require a template tag php ...
Anders Kitson's user avatar
0 votes
0 answers
34 views

Removing comment lines from all enqueued js files using a filter function

Is there a way to filter all enqueued javascript files and remove all comment lines without using a plugin ?
Kitiara's user avatar
  • 111
0 votes
0 answers
29 views

Modifying a WordPress Plugin

is it possible to modify plugin by removing action and then adding a new with new function? In plugin I have this: namespace OCDI; class ImportActions { public function register_hooks() { ...
Anton's user avatar
  • 1
0 votes
0 answers
15 views

Precheck fields when I add a new post

Precheck fields (like categery or custom fields) in new post based on user id. Its possible to make this?
Jose's user avatar
  • 1
0 votes
0 answers
122 views

ACF Flexible in TCPDF

So, i need to display Flexible content in TCPDF, i have my Flexible content fields: if( have_rows('levels') ): while ( have_rows('levels') ) : the_row(); if( get_row_layout() == '...
Lerry's user avatar
  • 111
0 votes
1 answer
24 views

Show data obtained from a function and place it in a shortocode function

I'm new I need to put a value obtained from a function and put it in my shortocode function if you can help me thanks $a=4; // value obtained from another function my_function($a); function ...
Stymark's user avatar
  • 37
0 votes
1 answer
184 views

CF7 select value get to function and reciept value from function

Si I try to asking different How I can get the value from following field: <label> Geburtsjahr/ année de naissance (Pflichtfeld) [select* annee include_blank "1940" "1941" &...
Beat's user avatar
  • 1
0 votes
2 answers
2k views

Conditional Homepage for logged in user

I want to change the home page url of wordpress site to another url when the user is logged in and have a specific role. Is this possible? Thanks in advance.
Nayan Chowdhury's user avatar
0 votes
0 answers
83 views

Fatal error: Call to undefined function load_theme_textdomain() in /var/www/vhosts/61/151172/webspace/httpdocs/wp-includes/functions.php on line 5

I am a complete rookie. Tried to hide the tags on my website & saw in a video if I add a code to functions.php it will do the job but instead I got the white screen of death. Oops. If I replace ...
Attila Magyar's user avatar
0 votes
1 answer
211 views

large image size of 1440x1440 not pulling 2x of 2880x2880 image

I have updated the large image size to be 1440px by 1440px on Wordpress, however it only pulls 2048 for the 2x. I have created a 2x size of 2880x2880 and have also updated 2048 to be 2880x2880 however ...
Matthew t Down's user avatar
0 votes
0 answers
226 views

Wordpress: I wanted to use Add rewrite rule multiple times for multiple CPT in my plugin

The below code is not working. I wanted to use add_rewrite_rule wordpress function for multiple post types but it works if i use it once. I want some one who can make this code work. function ...
Sultan's user avatar
  • 1

1
14 15
16
17 18
34