Stack Exchange Network

Stack Exchange network consists of 175 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.

5
votes
0answers
305 views

static variable loop not working in Wordpress

I have a function in my wordpress theme that deletes the first embedded video in a video post. See code below. This is in the functions.php file. /* - function that hides first video in post content -...
4
votes
0answers
200 views

Customize WordPress Media Manager - Media Window

Im trying to customize the wordpress media manager "add media" window to get it as simple as possible to use. So i want to disable/ hide the following fields/ functions because i dont need some or ...
3
votes
0answers
32 views

Get widget settings function?

I am using this to find if a new widget has been added or removed from my site: serialize(retrieve_widgets()); Works great for added or removed widgets. But it doesn't detect if a widget setting has ...
3
votes
0answers
416 views

Updating users_can_register option?

I have a custom setting page, where i have a radio to Enable or Disable Registration then try to update the wpoption (users_can_register). Screenshot: I've tried both true/false & 1/0 but it ...
3
votes
0answers
77 views

my function doesn't return my post from today

I'm using gravity form to create some custom post type - as events. Everything is working great, There is some date field to setup the event from x to y date. ALl of this working great. However, I ...
3
votes
0answers
37 views

Date/time limitation of posts where function must be executed

I have this piece of function in my functions.php file: function user_content_replace($content) { $sentences_per_paragraph = 3; // settings $pattern = '~(?<=[.?!…])\s+~'; // some punctuation and ...
2
votes
0answers
37 views

How to Replace Words with Hypertext Link But Ignore Previously Existed Links?

Auto-linking for "selected words" in the_content I am currently using the following code: function wp_affiliate_links($text){ $replace = array( '/ example /' => ' <a rel="nofollow" href="...
2
votes
0answers
21 views

Contact Form 7 - Delay auto responds

I'm looking for a way to delay the auto response (mail_2) from Contact Form 7 for 2 days. But I have no clue how to tackle it. I hope you have an idea. I'm using the following code in functions.php ...
2
votes
0answers
29 views

How to find out what blocks are added by a plugin

I am creating a plugin, which adds a number of blocks defined by JS/PHP as per Gutenberg documentation. I want to display these block names on an admin page. Is there a hook or function I can use ...
2
votes
0answers
249 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 ...
2
votes
0answers
111 views

How to change the page break <!--nextpage--> URL from ../post/2 to …/post/page2/

I am referencing the WP codex here: https://codex.wordpress.org/Styling_Page-Links but cannot find a way to customize the post URL for page break ( ) feature. For exmaple: instead of the traditional ....
2
votes
0answers
351 views

Search user metadata with checkboxes via ajax (almost working)

I have created an ajax search form following some tutorials online, it is working but not exactly how I need it to. Here is where I got the search from. I have US states setup as a user meta field ...
2
votes
0answers
42 views

Trying to inject twitter metadata into <head> using wp_head action in functions.php - get_the_excerpt() returns null

So I followed the "Add Twitter Cards without plugins" this tutorial for how to add twitter metatags into the header using the wp_head method. I have pretty much taken the code as is, and put it in ...
2
votes
0answers
950 views

Logging in redirects to correct page but shows logged out content until forced refresh

I'm trying to change some of the content being shown to viewers based on whether they are logged in or not. I'm using the is_user_logged_in() function in my child theme's functions.php to replace the ...
2
votes
0answers
570 views

Function to “Press Update Button” on all posts

tl;dr - I need the equivalent of pressing the "Update" button on many/all posts, without having to manually open each post and press "Update". I'm bulk importing from a CSV into WooCommerce, which is ...
2
votes
0answers
2k views

Move jQuery and Migrate to footer?

I've seen this answer, but I'd like to move Migrate as well. I'm trying to move both jQuery and Migrate to the footer and change the jQuery to the CDN version. Here is the failed code I've tried (Why ...
2
votes
0answers
877 views

bulk change of image setting “link to” to “link to: image url ”

i want every image present on my wordpress site with setting "link to: none" or "link to: post url" became in "link to :image url" ho make this for old post and for new post ? i tried this code in ...
2
votes
0answers
987 views

Overwrite Parent Theme add_image_size in Child Theme

I'm using a child theme of a parent theme. Now on my parent theme, theveloper adds some custom image sizes like this - if ( function_exists( 'add_image_size' ) ) { add_image_size( '...
2
votes
0answers
1k views

jQuery Plugin to use Wordpress functions in AJAX request

I'm using Chained Selects jQuery Plugin to create multiple chained selection fields. I'm using the remote version of the plugin to build the related options by means of AJAX request from a separate ...
1
vote
0answers
18 views

Wordpress website Rs changed to currency symbol

I have a wordpress blog website and all of a sudden in all of our blogs Rs has been replaced with a hindi currency symbol. I have tried checking out theme settings or any update in code which ...
1
vote
0answers
22 views

Why ajax doesn't work on certain wordpress hooks?

I built an ajax function which works perfectly when i hook it to admin_head or admin_notices hooks but it doesn't work when i hook it to manage_posts_extra_tablenav hook, instead of doing the ajax ...
1
vote
0answers
17 views

How to make custom posts types display when published for the future

I'm having a hard time accomplishing two things. I've created a custom post type for Events. I would like for the client to be able to post the event by the date. This means publishing posts that are ...
1
vote
0answers
47 views

Make Categories a Dropdown Menu in Media Library

I would like the categories menu to appear as a drop-down in both the list mode and grid mode view of the Wordpress media library. As of now, it only appears as a drop-down in list mode. List Mode - ...
1
vote
0answers
29 views

Move 'current-menu-item' class on #adminmenu li from Posts to Pages for Taxonomy Edit Screen

I've created a custom taxonomy called 'venuecategory' that is hidden by design(not attached to a CPT and does not appear in admin menu). When I'm on this taxonomy's admin page ('wp-admin/edit-tags....
1
vote
0answers
112 views

Tax query in pre_get_posts not working

I'm trying to filter the main query on the home.php template so I only shows posts from the latest issue taxonomy. What I have so far is the below but it is still showing all the posts on the ...
1
vote
0answers
17 views

WordPress Gravatar filter is removing my custom attributes

I am trying to add a style attribute on all the custom gravatar images. However, it is removing the style attribute before final output. Here is the code I am using: $background = ''; $args = [$...
1
vote
0answers
58 views

How to auto refresh when user change postcode

I setup the shipping zones so if the customer is in the local area and enter the correct postcode, "Free local delivery" become active and replace other zones. The problem is the customers is not ...
1
vote
0answers
35 views

trigger html cleanup for all posts

So i know that wordpress will auto clean / format html within posts / pages automatically when switching back and forth from text to visual: https://stackoverflow.com/questions/9907757/wordpress-...
1
vote
0answers
19 views

Facebook Messager Plugin

I deregister Wordpress's default jquery and register the latest jquery. The problem I faced with the Facebook Messenger plugin relied on Wordpress's default to function. Also when I hashed out the ...
1
vote
0answers
574 views

dynamic dependent select dropdown

I have a dynamic dependent select dropdown system that selects vehicle makes and models from a database which works fine but I would like to convert it to use and select parent and child categories ...
1
vote
0answers
11 views

wp-comment author- url +, email filter hook

Don't know how to change '@' and 'HTTP/S' in ALL comment-stuff, so those will be displayed in WP as unclickable contents. Do you have the knowledge and patience to straighten the following lines? ...
1
vote
0answers
281 views

How to use wp_trash_post (or wp_delete_post) for deleting a (or all) post(s) from custom post type?

I know, my question is general and here is some similar questions, I checked the all, but I dont find any solution for my problem... I try using the wp_trash_post() in my function.php, but for some ...
1
vote
0answers
297 views

Show the content that is after the excerpt using child theme

How do I set a value for $stripteaser using the functions.php file in a child theme so that when the_content() is called on post pages only the post exerpt is shown? I have a theme that I am using. ...
1
vote
0answers
53 views

Use third party Library in wordpress

The GA third party library works with php 5.5 and above, i have this. They say to install this via Composer, since i am new to php i have no idea where is it located and will this work on WordPress? ...
1
vote
0answers
212 views

When sale price is 0.00 show only regular price

I run my woocomerce product updates via excel sheet uploads with over 10,000 products. However, with the sale price/promo price column, I have prices of 0.00, 0 and some blank. I want a situation ...
1
vote
0answers
62 views

Custom shortcode outputs plain text instead of HTML at top of post

I am new to wordpress and coding and I need some help. I have a custom post type called 'endorsement' that would like to create a shortcode for that will output a list of posts sorted by a custom ...
1
vote
0answers
34 views

how can i use $_COOKIE[] + PostID to execute the below code?

someone can teach me how to combine $_COOKIE[] + PostID to count one visit by ip + post? I want use this to not use set_transient, my actual code is this: if( !current_user_can('administrator') ) { ...
1
vote
0answers
21 views

create a new page from a custom post type similar to an authors page

I am looking for some direction here as I am unsure where to start. I have a CPT called 'videos' and one of my inputs is a 'artist_bio' text box that creates a box with a biography in it on my page. ...
1
vote
0answers
50 views

Anon function and add_meta_box

I am building a WordPress management plugin (so far going really well) however I am having a slight issue below is what I am trying to acheive and the problem. I am building a Meta manager and for ...
1
vote
0answers
87 views

404 redirect to previous category

Hi I'm looking for code that I can place in my theme's functions.php that will redirect 404 pages to the previously viewed category. For example: If www.example.com/category1/item-name goes to a 404,...
1
vote
0answers
53 views

getting logged in user info (wp-load.php) from parent directory

Directory structure: https://www.example.com/test.php https://www.example.com/blog/wp-load.php test.php: require_once("blog/wp-load.php"); global $current_user; get_currentuserinfo(); print_r($...
1
vote
0answers
324 views

Remove the product category module block from the Woocommerce product page

I want to remove this block: https://imgur.com/a/xzuto this is a category block on the product page overview. I want to remove this block but I cannot seem to work it out. I find a couple of "...
1
vote
0answers
15 views

Function wont fire after custom post type is updated

I have a problem. I cant get this function to fire after a CPT called 'review' is updated on the front of the website. That's fine and the CPT updates with no issues but I need to function to fire ...
1
vote
0answers
142 views

Removing custom meta data

I wrote some code to add some custom meta boxes to my theme admin panel, and it works like a charm. The problem is I can't figure out how to make it so I can remove some of the data too. Example: I ...
1
vote
0answers
30 views

How to allow users to post only in certain category and hide elements from edit page?

I need your help, I am really desperate. In the beginning whenever a user is registered I create category with name based on that user's team name. That user also gets a unique custom role '...
1
vote
0answers
1k views

Fatal error: Call to undefined function cmsms_theme_page_layout_scheme()

I am using a modified version of the Social Activity theme from CMS Masters, and was trying to change the hardcoded versioning of the stylesheet in the header in order to reflect CSS changes I made. ...
1
vote
0answers
134 views

What's the uses of wp_cache_set() or wp_cache_add()?

I see many theme uses wp_cache_set() and wp_cache_add() functions and i can't understand how this function works. How are these functions useful for WordPress developers?
1
vote
0answers
33 views

What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?

I am wanting to change the text "Get New Password" to "Send It" on the lost password page. The following code is what I have in my functions.php file, but it is not changing the default "Get New ...
1
vote
0answers
501 views

how can I edit flexslider in woocommerce. [Urgent]

Can anyone please tell me how I can edit flexslider settings in woocommerce. I am actually trying to get this result. http://flexslider.woothemes.com/thumbnail-slider.html someone please help me ...
1
vote
0answers
219 views

How do I create a function that simulate the click on Update button for all posts?

I made a child function.php with this code. All new posts will automatically use the attachment id for the image I have uploaded to my Media Library. function wpsites_auto_set_featured_image() { ...