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.

0
votes
1answer
118 views

Display Data in Table from External Database in WP using Shortcodes

I have successfully coded a secondary database connection for my wordpress site in the functions.php file in wordpress. I have used the following to create shortcode and run the data to my table where ...
0
votes
0answers
118 views

echo Ajax function inside another Ajax function with foreach loop not working?

I'm really stuck with this :( I'm trying to echo function inside Ajax function with foreach loop for a list of users! To be clear: I have a list of followers/following users inside author.php, Then ...
0
votes
0answers
88 views

Using AJAX on frontend: Synchronous XMLHttpRequest deprecation except for admin role

Everything is happening in single.php. I have to validate if user has subscribed to the webinar and show login button accordingly. It's on the frontend. I'm doing this on document ready: <?php if(...
0
votes
1answer
25 views

error at login page in wordpress

hi today my wordpress blog in wp-admin and wp-login.php had an error Notice: wp_deregister_script was called incorrectly. Scripts and styles should not be registered or enqueued until the ...
0
votes
1answer
44 views

use add_action in a shortcode (gravity form - Wordpress)

I have a shortcode. With this one, i get the ID (number) of a formular $num_formular. Then, with this one, i had to send all the data in the database. When I run the following code, it works: ...
0
votes
1answer
40 views

change billing and shipping address 1 and 2 field placeholders [closed]

I'm trying to change the placeholder text for the billing and shipping address 1 and address 2 fields but I can't get it to change at all. This is what I have for billing address 1 // This function ...
0
votes
1answer
26 views

Assign IDs to headings in ACF using functions.php

I'm assigning IDs to each heading on my Wordpress site. It works fine for pages where I don't use ACF with the following code snippet in functions.php function auto_id_headings( $content ) { $...
1
vote
1answer
23 views

Shortcode content output but not in correct place

I have created a shortcode that gets information from an ACF repeater field... function display_websites_shortcode() { ob_start(); // check if the repeater field has rows of data if( ...
1
vote
1answer
58 views

is_user_logged_in() not working in AJAX validation call

Update: Error was a simple typo, disregard this question. I'm using the jQuery validate plugin to validate some forms. When I try to validate something using the is_user_logged_in() function, I get ...
1
vote
3answers
43 views

How to call plugin function per site in a multisite?

My goal is to be able to call a plugin function per site and of course it has different result based on the site data. e.g. I have a plugin called: sample-plugin.php Inside it has a function ...
1
vote
1answer
17 views

How to display the link (title) and thumbnail post?

I found this related post code here, but the code calling it is incomplete, it only shows the article title. How do I make the links and thumbnails appear? I really hope someone helps, because this ...
0
votes
2answers
27 views

Where paramaters of a custom function are coming from inside the loop?

I have this piece of code and, although it works, I do not understand how. First, I created a custom post type into my mu-plugins folder: function actor_init() { $args = array( 'label' => '...
0
votes
1answer
106 views

Remove generated category and tag class names from woocommerce product & blog listings markup

I noticed in my wordpress/woocommerce setup that every time i add a tag to a product or a blog post. It adds that tag as a class into the listed item (Product/blog) I also noticed it adds a class in ...
1
vote
2answers
22 views

Print last modified date only on posts

I'm printing the last modified date via functions.php with the following code function wpb_last_updated_date( $content ) { $u_time = get_the_time('U'); $u_modified_time = ...
0
votes
1answer
37 views

Setting Up Child Theme To Take Priority

I'm trying to setup my child theme style sheet with a premium theme I have bought but I'm having a nightmare trying to get to work properly and efficiently. I have downloaded the theme's child theme ...
0
votes
1answer
26 views

PHP question: how to combine syntax?

could someone please tell me where the mistake is in my PHP code? My PHP knowledge is extremely rudimentary although I have tried it with http://php.net/manual/de/language.operators.logical.php :-D "...
0
votes
1answer
35 views

Unable to declare AOS library in functions

Greeting WP Devs, I am planning to transfer the script libraries in my function.php . In my function.php I registered AOS function mypage() { if ( is_page( 'mypage' ) ) { wp_register_script( '...
0
votes
1answer
33 views

How to check if a Customizer setting is set?

I'm trying to setup a function that writes a meta tag into the header of my site. Namely, I've set up a color chooser input like this: function customizer_options($wp_customize) { $wp_customize ...
0
votes
1answer
25 views

allow only one post in specific category

I have a category called "best post". When the editor selects this category in a post and publishes the page, a PHP routine must check if other posts have this category, and if so, this category must ...
0
votes
0answers
11 views

Backend overview pages in different sections

Is it possible to edit the WordPress admin overview of pages: /wp-admin/edit.php?post_type=page into sections based on post meta values? So for example I got 3 pages with the meta value of "Planten" ...
-1
votes
1answer
33 views

syntax error, unexpected '$id' (T_VARIABLE) - where is the issue though? [closed]

This function below throws the following error: "syntax error, unexpected '$id' (T_VARIABLE)" This function and question is related to this post. function so328323_prefix_title( $title, $id = null ) ...
0
votes
1answer
33 views

Is it possible to insert text into an html tag using functions.php?

Here's what I mean: I am using a plugin called 'pods' which allows for the creation of Custom (CPT) and for relationships to be formed between those CPT's. However - there's a little flaw that I can ...
0
votes
1answer
119 views

I want to customize the_posts_navigation function by replacing prev and next with images

Hie, I am currently trying to customize the function 'the_posts_navigation' of Wordpress because I would like to let appear only "previous" and "next" (which I want to replace by icons of arrow in ...
0
votes
1answer
20 views

Author Date Function not working as expected [duplicate]

I am trying to get whether the author has posted within the last 30 days but this returns TRUE even if the author hasn't posted within the last 30 days. <?php $args = array( 'post_type' =>...
1
vote
2answers
52 views

How to use thumbnails in gallery?

Since Wordpress 5.x they've removed the thumbnail size option for galleries. Is there a way to activate or build a workaround? I like to build up a classic Lightbox gallery.
1
vote
2answers
75 views

Adding ads code between comments

I am showing comments on my page. I want to show 1 ad after every 2 comments. <div class="panel-ads clearfix"></div> it's repeating the number of comments. I would like to add the ad ...
0
votes
1answer
20 views

Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)

I can't find the answer for my question anywhere. I am trying to make a login redirect script, after login the user (depending on their role) will go to a certain page. I have currently a working ...
0
votes
1answer
13 views

Removing full title and breadcrumb header container for a specific post type

I have been looking around at how to remove the header container but only for a specific post type with php in the functions.php file of the child theme. For example, portfolio or events. Is this ...
1
vote
2answers
34 views

Adding HTML to the end of every post with the Block Editor

I'm converting my posts over to use the new Block Editor. In the past I added an icon to the end of every post to act as a signature and marker saying the article is over (like print magazines do). I ...
0
votes
1answer
20 views

Send email with list of active plugins upon activation/deactivation

I'm using Airtable to keep a real-time list of plugins for multiple WP sites, and have an almost-working setup with Zapier emailing new plugin data when a plugin is activated or deleted. The email ...
0
votes
1answer
61 views

How to display more audio file ID3 tags in WordPress

When adding an audio file to WordPress, it automatically takes the title, album, artist from the ID3 tags in the mp3 file. It uses these in the playlist and audio file attachment page. How can I make ...
0
votes
0answers
63 views

wp_footer hook causing text to show on bottom of page

The below function is causing the resulting options to display on the bottom of the page (under the footer area) when the search bar is activated / being used. Oddly enough, it seems like this is by ...
0
votes
1answer
131 views

How to get Post Type from the functions.php file

TLDR: How can I get the post type within the functions.php file? I am trying to add the following code only when the post type is a 'page' and not when it is a 'post.' However, I am not able to call ...
0
votes
1answer
43 views

Execute function after a post has been published

I'm using a post crawler on my website that pulls articles from other websites and automatically publishes them on my website. During that process, it checks for any video embed codes; if they exist, ...
0
votes
0answers
7 views

How to move Main Menu position?

I am trying to move the main menu a bit to the left. As you can see in the image below, the orange button is covering some parts of the text and there is still space on the left part next to the logo. ...
0
votes
0answers
10 views

wp_nav_menu_items add custom item 2nd, not last

I have this function that adds menu items to my menu...My question is, is it possible to have them 2nd in the menu and not last? function ur_add_loginout_link( $items, $args ) { if (...
0
votes
1answer
258 views

How to properly set custom logo size?

According to the Codex page about adding a Custom Logo, one has to add the following code to functions.php: function themename_custom_logo_setup() { $defaults = array( 'height' => ...
1
vote
1answer
26 views

Function to check if author has posted within the last x days

Is is possible to check whether an author has posted in the last X days? I am currently using this function to determine whether he has posted at all. $args = array( 'post_type' => '...
-1
votes
2answers
18 views

Loop (iterate) through Multi-Site sub-sites (blogs)?

What is the easiest approach to iterate through the sub-sites (in Multi-Site network) and let's say add_option("xyz", 123) for each of site.
0
votes
2answers
54 views

How to use selected WordPress functions?

I have a custom PHP file on which I want to use some WordPress functions such as wp_get_current_user(). I've tried requiring wp-load.php, but that increases the load time significantly as it loads all ...
0
votes
2answers
46 views

Solved: redirect to another page using functions.php

I want users to change their avatar on a general site, because some plugins only work with that. for example www.example.com/members/user1/profile/change-avatar/ And www.example.com/members/...
0
votes
1answer
48 views

How to get current post category details inside “loop”?

I have a rather simple problem I can't solve. I have custom styling for my cards and one of the elements of the cards is the category, when I access the_category() from the Loop it comes with its own ...
0
votes
1answer
39 views

How to disable/enable a plugin at a specific time

Is there a hook that would allow me to disable and enable a specified plugin at a certain time? For example, I would like to disable the wp contact form 7 plugin every Tuesday at 6 AM and enable it ...
0
votes
2answers
81 views

enqueue_script with filemtime javascript not working

Hey guys so I'm trying to enqueue a javascript with filemtime but every time I do it the custom js script I wrote doesn't seem to enqueue. function add_js_scripts(){ wp_register_script('lib', ...
0
votes
2answers
50 views

ACF not showing

I have a (weird) issue - can't get the ACF field to work on my page. I have a simple text_field and it shows on the Homepage page section: ACF settings: Homepage settings (when I refresh the panel ...
2
votes
1answer
13 views

Query children and parent title

i'm query child pages of a page ID. How can i echo the parent page where it says "PARENT TITLE ? Using <?php echo get_the_title( $ID ); ?> is not an option. <?php $args = array( '...
0
votes
1answer
21 views

Call do_action() within WordPress cronjob

I've programmed a cronjob in WordPress which get's executed every 5 minutes. In the function of the cronjob im trying to perform a do_action: error_log('Send Email'); do_action( '...
0
votes
0answers
49 views

how to remove a tag in the_category function

https://core.trac.wordpress.org/browser/tags/5.0.3/src/wp-includes/category-template.php#L0 line:195 //line 195 default: $thelist .= '<a href="' . esc_url( ...
0
votes
0answers
23 views

How to make a slug from GET request to other page and then retrieve it as variable?

Let's say i have custom page site/wordpress/id/ How can i: Send get request to it the right way with form that has 1 input "id" what action should be in that form? Make it look like guest is on the ...
1
vote
1answer
28 views

Can I hide certain upload folders in media library [duplicate]

A Plugin ( download monitor ) saves uploaded files in a certain folder called "dlm_uploads" within the WP upload directory. All files are visible in Media Library. Unfortunately the upload path cannot ...