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

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
6 views

Combine two different filter callback functions

I am currently using this code which works fine. function add_data_attribute($tag, $handle) { if ( 'chargebee' !== $handle ) return $tag; return str_replace( ' src', ' data-cb-site="...
0
votes
0answers
27 views

Add IF Condition to array?

I am trying to add IF to an array. To hide a few specific arrays from everyone but super admin. This is what I have come up with: protected static function populate_fields_array() { function ...
0
votes
0answers
10 views

Get Billing Email from WooCommece Checkout and Pass to Fullstory JS

I'm using WooCommerce on WordPress where I've integrated Fullstory snippet in the header of my site. I've enabled checkout for guests, that is, they can check out without creating an account on my ...
0
votes
0answers
25 views

Get posts by id using shortcode

I am trying to get posts by id using shortcode [testimonials id="272"] in functions.php file. I used the below code it is working but not able to get posts by id. Can anyone help me with this issue if ...
1
vote
1answer
23 views

Possible to display shortcode based on the category?

So, aside from creating individual WordPress Category PHP Pages, I'd much rather have a functions.php command that would insert shortcode when a Category has been selected. How would I go about that, ...
0
votes
1answer
7 views

How To Display Author Popup on Entry Meta (Genesis Framework)?

How to when the mouse pointer on the author name can display Author Popup like this site? https://www.dietdoctor.com/low-carb/keto Thank you!
0
votes
1answer
13 views

Change wordpress current_time function to different timezone

I'm using plugin to set the earliest possible date for order delivery in woocommerce. Piece of code below: $current_time = current_time( 'timestamp' ); if( $prdd_minimum_delivery_time != '...
0
votes
1answer
17 views

function replace_text for entire page

function replace_text($text) { $text = str_replace('old-text', 'new-text', $text); return $text; } add_filter('the_content', 'replace_text'); Is there any way to apply this to entire page? I mean ...
-1
votes
0answers
9 views

Custom post Data fetch In Contact Form 7 when open click via Button

Hi friends i want to get my custom post title in contact form 7 input value when user click over button and contact form 7 open in next page than in that page my custom pots article get in that form ...
0
votes
0answers
13 views

Overrided parent function in child theme not load next content

So I want to change top header line display. To do that I'm trying to override parent theme function with my edited function. When I do that my function override parent function, but next page content ...
-1
votes
0answers
34 views

Wordpress shortcode for contact form 7 does not work [on hold]

I'm trying to add a function shortcode for wordpress contact form 7 to obtained information by $_POST but it is not working only appear the tag [cs7], what could be happening? Does anyone know how ...
0
votes
1answer
37 views

Why i can't get custom fields value or post ID via Ajax?

I wrote a code that generate a link based on the visitor location and it worked perfectly but i discovered that the generated code get cached since i'm using a full page caching so i though to solve ...
0
votes
1answer
22 views

Is it possible to replace 'attachment' with another word?

The goal is to replace the word 'attachment' in attachment URLs to read another word, so vising an attachment would be like: site.com/category/article-name/NEW-WORD/attachment-name/ Is this even ...
0
votes
1answer
19 views

How to call a function from functions.php with ajax?

I'm wondering how can i call a function from functions.php and print it with Ajax in a specific place (woocommerce_before_add_to_cart_button). I know i can simply add my function in add_action like ...
0
votes
1answer
25 views

Send mail to author when custom post type is saved

I have a custom post type called "documents". I can add documents (ACF repeater field) there and the users can see them in a frontend-view. Now i need to send an email-notification to the author of ...
0
votes
0answers
7 views

Get metadata to display using .medialelement player for live streaming

I use the mediaelement audio shortcode for our shoutcast radio station site, because I didn't want to use a plugin or external javascript. I want to get the metadata from our live or auto-dj radio on ...
0
votes
1answer
26 views

How to add 2 posts under another post? Formatting should be intact

The goal is to print 2 articles under an article IF the article is 200 words or less. I've had some help over at WordPress, but the code a couple of helpful people provided I can't integrate into a ...
0
votes
0answers
14 views

update_user_meta() not working in ajax function

My goal is too allow users to upload their own avatar images to my site. I can successfully upload files to my site but when I try to add them to the user meta it does not add the meta entry. Here ...
-1
votes
1answer
23 views

Most efficient way to get custom database records from 20 buttons and 20 tables?

I have 20 buttons on a member protected wordpress page and each button gets a random record from a different custom table in the wp_ database. @janh provided a solution here to get the random record ...
0
votes
0answers
31 views

Woocommerce or Wordpress , changing default settings

Im looking for a solution to change default settings, for example: In the picture you're seeing (attached) Default = Enable And i want Default = Disable i want to set default to disable, ...
0
votes
1answer
14 views

Read array in php?

I'm trying to add some custom user meta on the registeration. For example, I have field to set a fruit : function some_fruits($fruit= false) { $fruits= array(); $fruits['1'] = 'Apple'; $...
0
votes
1answer
12 views

Undefined index: action with code-snippets to change register page

I see this error Notice: Undefined index: action in /home/olexywro/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(352) : eval()'d code on line 6 in my login page with this code ...
0
votes
0answers
21 views

Notification for users based on saved search queries

I have been working on a saved search functionality and it's almost complete, I just need help with the very last part of the equation. I was able to run a wp_query which checks the found_posts of a ...
0
votes
1answer
13 views

Native gallery custom html output

I've added image gallery to my page via Add Media > Create Gallery. I don’t want to output default html of the gallery, neither are sufficient options to change gallery sortcode's attributes: itemtag, ...
0
votes
1answer
12 views

Changing author links on homepage to buddypress profiles - without affecting ability to link to author archive throughout the site

I've set all author links to head to the author's buddypress profile rather than the author archive page. I've done this through my child theme's function.php file. *add_filter( 'author_link', '...
0
votes
3answers
34 views

Is it possible to return content, and then also continue to do other things?

Please see my shortcode script below (which is intended to print the next 15 minute time interval, eg if the current time is 9:01pm, it would print 9:15pm). I have managed to produce the correct ...
0
votes
0answers
8 views

Force Customizer to show widgets in page with no sidebar

Hi i have show the widgets in front-end with this function to have complete control on html: https://gist.github.com/kingkool68/341818 how can i tell to wordpress that i have a sidebar active witout ...
0
votes
1answer
14 views

How to delete specific element when it is not homepage?

Also here i have a simple post: <a href="/allgemeinen/me-libe-love-y/"> <p class="erfg" class="quotes">bla bla bla blas</p> </a> when it is homepage, or pagination or ...
0
votes
1answer
18 views

WP All Import / Update stock quantity from multiple XML files

Hi there as the title says, I am trying to import stock quantity from multiple xml files, I am trying to save stock in custom filed and then add code to sum this new filed and existing new and then ...
0
votes
0answers
9 views

Return all published WooCommerce products, that are not in user's Cart (or Subscription)

Using WooCommerce/WP, suppose one has a list of products in the current user's Cart, or in their current Subscription — call that $current_products. Of course, there's also a list of all published ...
0
votes
0answers
38 views

i can't use wordpress functions in ajax loaded php file

I want to make a chained select like this brand > model for that i make a file named cat.php in my themes folder that contains this code <div id="categories"> <?php $args = array( ...
0
votes
1answer
46 views

Trying to load JavaScript only on pages within a PODS category/ custom post type

I'd like to load CSS but only on certain pages. This code normally works great but I cant figure out the 'Conditional Tag' what will only load these pages. This is the function I place in my ...
0
votes
0answers
18 views

Loading travelpayout plugin search result within wordpress theme page [closed]

I want to load the search result of Travelpayout plugin within my wordpress website. Please check this link My Website Link How do I make it load between my header menu and footer of my wordpress ...
0
votes
0answers
9 views

wp_delete_post / wp_update_post not working but update_post_meta does

I cant seem to get the first two functions to work. I've tried multiple posts of the same post type but I cant delete or make any changes to the post but I can update any post meta. Any ideas as to ...
0
votes
0answers
9 views

Prevent duplicate uploads?

I created an external upload script for bulk uploading post on per line basis of course the context of this will be hard to see without seeing it, so I attached an image. Each line using my script is ...
0
votes
1answer
12 views

How to add link rel tags on paginated posts?

I'm using the following code in functions.php to add rel prev/next tags to paginated contents: function add_rel_nextprev_to_paginated_content() { global $paged; if ( get_previous_posts_link() ) { ?&...
0
votes
0answers
23 views

How do I create a function for WordPress PODS? [duplicate]

I am using a Plugin that creates Custom Post Types called 'PODS' One of my fields displays a date from a calendar using the settings time format within WordPress, which displays like this: September ...
0
votes
0answers
24 views

Custom Login Integration not working in wordpress anymore

I have added a script in my functions.php file which checks a second custom database within the WordPress database when a member tries to login. This script was working correctly in the past and I ...
0
votes
0answers
15 views

Add another role to a user when they click a button?

On my site, there are roles "user, authors, etc.". Default role for user is "User" which I want to keep it for all users. How to add another role to a user when they click a button? I tried with my ...
0
votes
1answer
50 views

Woocommerce - Removing Cart button for specific product category when product of another specific category is not in cart

I am trying to remove Add to cart button from products under "car_tickets" category when any product from "bus_tickets" category is not in cart. This is my code so far. add_action('...
0
votes
1answer
24 views

How to rewrite url for any specific taxonomy?

I have custom post registered it's archive has url example.com/doctors It's Single post has url example.com/doctors/john-cardiff It has categories as well, for example for cardiology category ...
-2
votes
1answer
15 views

Inject class in body when particular page template is used

<body <?php body_class(); ?> > In header.php I have written the above code. But I want when this page template is in use: page-customer.php then body_customer class should go above. ...
0
votes
1answer
15 views

Custom Bulk Actions handler not firing

I'm pretty new to Wordpress and PHP and am trying to add a custom field to a bulk edit list for a custom post. I've followed the following blog post but my handle_bulk_actions callback is not firing: ...
0
votes
2answers
33 views

Woocommerce - Switching Price for Category

I am looking for the function to change position the price for the category. (I attached an image). Ok, is not a switch is a remove and add. ¿Where i can find a good explanation about the php ...
0
votes
0answers
80 views

Creating a “Related Meta” type field?

I need a unique meta box which can contain auto-updating elements similar to how a tag cloud would appear. Example. identifier id : animals identifier data : Dog, Cat, Horse, Pig I need to know ...
-1
votes
0answers
19 views

Delete meta_key from wp_postmeta using theme function

I am having large database due to wp_postmeta, I checked and i found out that meta_key named post_views is what is causing the huge data. So I ran the sql query DELETE FROM wp_postmeta WHERE ...
0
votes
0answers
21 views

subtracting the current post form then whole loop, which is generating all CPT titles

<select class="title_select minimal"> <?php $loop = new WP_Query( array( 'post_type' => 'plugin', 'posts_per_page' => -1 ) ); ?> <?php ...
0
votes
0answers
22 views

Deleting the Default Canonical Tag and Inserting a Custom Tag for a Single Category

I need to be able to delete the default canonical tag for all posts in the category 'rezept' and then create a new custom canonical tag because I have modified the URL string for this category to ...
-1
votes
1answer
20 views

How to write a query-function as a query-shortcode?

I ask this question as a follow-up to this one. I have this query-function in functions.php but AAMOF I don't want to change functions.php at all (besides for CPTs). I'd like to print the same data ...
-2
votes
1answer
21 views

Creating mixture of shortcodes to use in the visual/text editor

I am attempting to make a page on my site that has a mixture of different kinds of content. So I'd like for the first part to just be the_content, but then beneath it calls to posts under specific ...