Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
346 votes
108 answers
169k views

Best collection of code for your 'functions.php' file [closed]

As with many others who are now viewing this post, I have been reading various blogs, forums, and discussion groups to learn and improve my WordPress skills. Over the past 12 months I have been on a ...
0 votes
1 answer
55 views

Simple ajax request with Vanilla JS keeps given 400 Bad Request

I am new to Ajax and hope someone can help me with the following. I am trying to make simple ajax test in wordpress, but getting al the time a 400 Bad request. I am really wondering why this is not ...
Brango's user avatar
  • 1
0 votes
0 answers
14 views

Remove posts that start with similar words (like a delete duplicate posts plugin)

Can anyone advise on a SQL query or plugin (or any other solution, as I haven't been able to find any) that can delete all posts that start with the same words, except the oldest of them? Or maybe to ...
Johnny Bravo's user avatar
0 votes
1 answer
24 views

How to access a function declared in child theme's functions file in a plugin file?

I have a function declared in my child theme's functions.php file as seen below: function test_fn(){ error_log("Test fn"); } When I am calling this function in a plugin file, I am getting ...
dc09's user avatar
  • 195
0 votes
3 answers
845 views

wp_enqueue_script doesn't load JS in plugin

I wrote the following code in a standalone plugin, but it doesn't work Please guide me how to modify the code, so the JS file is loaded. <?php /* Plugin Name: Copy post */ class CopyPostApi{ ...
Fardad Farhang's user avatar
0 votes
1 answer
89 views

stop resize button for wordpress media

The images in my WooCommerce product gallery do not need to be resized I only need the original image to display. Is there a way to add a toggle button to wordpress media to tell it to generate other ...
Monoor's user avatar
  • 13
0 votes
1 answer
41 views

Secure way to add JS Script to Wordpress filesystem

EDIT: Because of the answers below i changed the title and explanation for this question. Maybe there are other people who struggle with saftey questions, like me. I am a beginner with Wordpress ...
LovinQuaQua's user avatar
1 vote
1 answer
96 views

How to get next day date of a specific day

I have created a shortcode in WordPress to show next day date of a specific day but it does not show the correct date when I am passing the parameter through the shortcode. Can anyone tell me what I ...
v morgesh's user avatar
1 vote
0 answers
77 views

Possible to overwrite load_template function in plugin using functions.php

So, I am currently using a Wholesale plugin for Woocommerce which, by default, redirects users to it’s own Wholesale Store page. The caveat is that the Wholesale Store page only uses the archive-...
jayciemota's user avatar
96 votes
3 answers
44k views

Between functions.php (theme), widgets, and plugins, which is loaded first?

Customer asks if a specific carousel plugin he uses can be widgetized. That means I should create a widget inside functions.php which calls the plugin's function. That means that the plugin's code has ...
pixeline's user avatar
  • 2,877
0 votes
1 answer
69 views

Mixed results with is_page() WordPress function, when using $this, or self

I'm converting an old plugin from PHP5 -> PHP8 and I came across this check, which caused an error when executing: Notice: Accessing static property PropertySearch::$listing_details_template_name ...
level42's user avatar
  • 113
8 votes
7 answers
12k views

Gutenberg disallow certain custom blocks but keep all core blocks?

I'm writing a function to allow only some custom blocks - essentially I want to register all the blocks, then based on a database table of 'selected' blocks disallow any other custom block. I can ...
Aravona's user avatar
  • 585
0 votes
0 answers
29 views

add to cart linking to add to cart page

I am making a website in Wordpress and created a custom shortcode for loading the products. That is working fine, however when clicking the add the cart button, if redirects me to the cart page, where ...
Brango's user avatar
  • 1
0 votes
1 answer
26 views

How to call a logging function from a generic utility plugin from another plguin

I want to add some logging to my plugin, and for various reason want to create my own wrapper function around error_log(). And for reusability, I'd like to stick my wrapper function in a separate ...
florismk's user avatar
2 votes
1 answer
2k views

Override the plugin class and function

hope somebody could help me. I have bought one plugin. But I need to change the function of the plugin in my child template functions.php Here is the classes and functions of the plugin. I need to ...
Down's user avatar
  • 31
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
86 views

Shortcode cannot parse attributes within double quotes. " is becoming ” breaking my shortcode

I made a plugin that creates a shortcode to calculate the time since a particular date in the past. It has two attributes, a date string and units: function timesince_shortcode($atts) { $atts = ...
Sidewinder's user avatar
0 votes
0 answers
57 views

Why nested REPLY not working in WP Comments?

<section class="postcomments"> <div class="comlist"> <h3><span>—</span>Comments<span class="comcount"><?php echo ...
WordCent's user avatar
  • 1,877
3 votes
1 answer
2k views

Can we completely remove the WordPress Sitemaps (WordPress 5.5)?

I have been using my WordPress site to create various types of content, I obviously submit my sitemaps to Google for getting my site indexed. But there is some content which I don't want on Google, ...
Aditya Agarwal's user avatar
1 vote
1 answer
825 views

creating html reusable blocks via shortcodes

I'm using a really simple and fast theme in order to reach a good speed score, so i'm not using any visual composer, but writing my own sections in pages via html i have some sections and cta that i'...
Robert's user avatar
  • 111
0 votes
1 answer
5k views

Woocommerce singe product custom gallery output works just on the first slide

I copied the "product-image.php" to my theme folder in order to change the HTML output a bit, so instead of using wc_get_gallery_image_html I created my function and changed the output there....
Darko's user avatar
  • 146
0 votes
1 answer
23 views

Read page- or post-content across different builder-plugins

I am currently working on a WordPress-plugin to analyse post- and page-content. The plugin contains a php-function that read the post- and page-content across several different builder-plugins (such ...
Dennis's user avatar
  • 103
0 votes
0 answers
56 views

Import posts from a different database with the same old id

I am trying to retrieve data from an old custom programming to a new WordPress site, but I encountered a problem that I cannot retrieve the old id number. I need that to keep the site's archive, the ...
Kami's user avatar
  • 1
27 votes
4 answers
42k views

Disable plugin / plugin action via theme

I have installed the Google Analyticator plugin on my site. I am also using the MobilePress plugin to serve up a theme designed for non-smart-phone mobile browsers. I have set up Google Analytics for ...
PNMG's user avatar
  • 1,381
0 votes
1 answer
77 views

How can I save the selected page in the dropdown after anyone clicks on Save Changes?

I am trying to build a function for my plugin. Now, I am displaying the dropdown of all available pages. What I want is for when anyone chooses a page from there and clicks on Save Changes, the page ...
Rajin Sharwar's user avatar
0 votes
2 answers
2k views

how override a define

i have this define define('DISALLOW_FILE_MODS', true); but i need to execute a function with the define set to false. is it possible and in case how?
DevBeppe's user avatar
0 votes
1 answer
42 views

I want to allow certain file types on dokan upload files

Before we get started, I have tried alloweding "UPLOAD_UNFILTERED_FILES" thing on config.php and i have tried allow different mime type plugins, none of them worked I want to allow .rbxlx, ....
ItsBenny_'s user avatar
0 votes
1 answer
91 views

PHP Creating a formula from mysql db values and db stored math operator

I am trying to use variables stored in a DB and math operator (e.g. * + - /) to allow users to build formulas e.g. (Night Shift Hours*Night Shift Time Rate)*0.2 The formula string is build from ...
GURU mcewan.marriott's user avatar
-1 votes
1 answer
363 views

Option value not getting updated until page refresh in WordPress

I am building my WordPress plugin. There, at first I am using a checkbox, and then updating the value from the checkbox (yes or no) in the Database. Then, from later on I am fetching the value form ...
Rajin Sharwar's user avatar
0 votes
1 answer
221 views

Activate and deactivate two plugins automatically at certain hours

How I can Activate and deactivate two plugins automatically at certain hours? For example, I want the "akismet" plugin to be active only from 10am to 7pm and the other Times deactivated. and ...
user168547's user avatar
0 votes
0 answers
208 views

How to disable hover zoom on woocommerce. None of the common methods work

I have tried these codes in child functions and style files. Nothing works. add_action( 'wp', 'divikingdom_disable_wc_zoom', 99 ); function divikingdom_disable_wc_zoom() { remove_theme_support( '...
Raj Arjit's user avatar
  • 103
0 votes
1 answer
815 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 ...
ali pik's user avatar
  • 19
0 votes
0 answers
51 views

Run a function only once when logging into dashboard

I want the Pro version of my plugin to do a version check once when an Administrator logs into the dashboard. At the moment I am connecting to my API using wp_remote_get() in the main plugin file, but ...
Steve's user avatar
  • 297
27 votes
4 answers
36k views

Manually set global $post vars with an ID, in order to use template tags

I have a function retrieving ID's of posts by very specific means. I need to be able to set the global $post in order to use functions like the_content(), which does not allow an ID as a parameter. ...
Mild Fuzz's user avatar
  • 4,190
3 votes
1 answer
2k views

Extend Elementor Archive Posts widget with a custom skin in order to show multiple badges

I modified my posts widget in Elementor with a custom skin in order to show multiple badges with following code: /* MULTIPLE BADGES ON POST */ /* --- */ add_action( 'elementor/widget/posts/skins_init',...
BarrieO's user avatar
  • 99
0 votes
1 answer
213 views

Checkbox show / hide output result

How can i fix a show / hide function in my plugin. The checkbox called "snup_check" at line 257 should be standard unchecked. If the checkbox is unchecked nothing should happens. If the ...
bjovaar's user avatar
  • 21
36 votes
4 answers
10k views

Where do I put the code snippets I found here or somewhere else on the web?

Many posts here or somewhere else contain code, but they do not say where to put it. Example: I have found this post: How do I turn off 301 redirecting posts (not canonical)? I'm a newbie with PHP. ...
Carl's user avatar
  • 361
0 votes
2 answers
76 views

Cannot get wpdb data (Error in a simple fuction) [closed]

I'm using Cryto Plugin and want to get coin price data from plugin db. For easy practice, I'm trying to get BTC data. <?php function get_coin_price($coin_symbol) { global $wpdb; $coin_price = ...
Morty_Smith's user avatar
0 votes
1 answer
296 views

auto activate plugin when theme is active

i have a class to activate the plugins when i set my theme to active but the class auto activate all plugins , how i can modify to activate only the plugins that i choose. if ( ! class_exists( ...
Crash Point's user avatar
-1 votes
1 answer
58 views

Make plugin admin page visible to other roles

I have created a plugin that I want users with the role of 'Editor' to be able to see and use in their admin panel.Currently, only administrators can see and use this plugin. I believe it has ...
Pelle Nilsen's user avatar
0 votes
1 answer
964 views

Soflyy WP All Import Custom File Download Issue

I need to send a user id to a remote server to download an XML file. I accomplish this with the snippet below: function custom_file_download($url, $type = 'xml'){ $ch = curl_init(); $...
Stradders's user avatar
0 votes
0 answers
61 views

WordPress Custom Page Blog Template Pagination Problem (Pagination Not Displaying)

My website doesn't display pagination no matter what I do or try. Can you help me, please? Tried a lot of different codes and Plugins but no dice. Here is the code for test template: <?php /* ...
gfo95's user avatar
  • 25
0 votes
1 answer
47 views

What is @Action in Wordpress?

I have found this code snippet on a plugin. /** * @Action(name="workforce_content_loop_before", priority=10) */ public static function show_breadcrumb() { echo do_shortcode( '[...
Avijit Palit's user avatar
0 votes
1 answer
3k views

Use action, filter, or hook to append HTML to WordPress plugin function

I am new to WordPress actions, filters, and hooks, and am wondering if it is possible to use one of the three to append some HTML to a defined plugin function using the theme's functions.php file. The ...
Mike Hermary's user avatar
1 vote
0 answers
190 views

Load CSS before Theme CSS

I have a stylesheet I want to load first in the head before other plugins load css or theme css. For some reason priority is not working for me. Any idea how I can achieve this? I need to use ...
Ads's user avatar
  • 11
0 votes
2 answers
1k views

How to make a dynamic css class whose name changes every visit to confuse scraper

I want to make the page classes changed dynamic depend on time or anything else to force the type of scraper that depend on my site classes or the classes like content, entry-content .. etc. How can ...
Muhamed Ahmed's user avatar
1 vote
2 answers
605 views

Scope for PHP Variables Assigned in functions.php or a plugin

I'm a web developer who works on WordPress sites and want to ensure I keep PHP variables out of the global scope. I have questions about this: If I created a $new_title = "test seo title"; ...
risingPhoenix1979's user avatar
1 vote
4 answers
5k views

How to set Noindex to all wordpress pages in a catergory?

I have a standard WordPress page category with tag_ID=92 which I want to noindex all posts in this category entirely. Is there a way to do it with actions/hooks in functions.php?
File_Submit's user avatar
0 votes
1 answer
56 views

Create Wordpress category dynamically

I have more than 15 Category , And i have a custom taxonomy "classroom", Is there any way to Create those categories automatically when i activate plugin?
Hello world's user avatar
0 votes
2 answers
2k views

How to disable register and reset the password from WordPress admin panel?

How to disable register and reset the password from WordPress admin panel? Please I want to do this by codes without using plugins.
Yogu's user avatar
  • 85

1
2 3 4 5
11