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.

learn more… | top users | synonyms (2)

1
vote
1answer
91 views

Global functions on WPMU

I work in a multisite environment where all of the sites are related. A lot of recent developments have required me to copy and paste certain functions into many different theme folders, which causes ...
0
votes
1answer
84 views

Add login hyperlink to secondary navigation menu

I have the following lines of code in my functions.php file: #-----------------------------------------------------------------# # Custom menu ...
3
votes
2answers
2k views

wp_enqueue_script was called incorrectly

Hello I don't know how but now I am getting this error Notice: wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, ...
0
votes
1answer
25 views

Connecting to a 2nd DB gives me no results when querying

I'm trying to access a different DB on the same localhost as my wp db is and I did this like so: functions.php: add_action('init','my_new_db'); function my_new_db(){ $newdb = new wpdb( 'test', ...
0
votes
2answers
250 views

Override default password nag in Wordpress

For some reason my default password nag is playing up on a big multi-user site I've setup. Pretty sure it's got to do with the New User Approve and Gravity Forms User Rego combo that I'm using. ...
0
votes
0answers
35 views

Adding ID to a Listing but not inside WP_Query while

<?php $args = array( 'post_type' => 'bedrijf', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC' ); ...
3
votes
1answer
186 views

Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?

I am looking for solution to auto delete images of old posts in WordPress site. I want to hold images of current 50 posts, others should be deleted automatically. It can be function to delete on time ...
1
vote
1answer
42 views

wp_trash_post function to only apply to posts, not pages!

I have the following function that deducts at point when a post is removed. But when I remove a page, the wp_trash_post is also called. // Remove 1 point if their post get removed function ...
0
votes
1answer
202 views

Foreach loop returning more than one item when querying taxonomy

I am querying the taxonomy terms and then listing the posts that are under those terms. The taxonomy is basically a category for a custom post type, and the terms in it are the categories. I didn't ...
0
votes
2answers
81 views

How to use scripts when header/footer are stripped out

I'm working with a client who is wrapping the body of our WordPress site with their own external header and footer, stripping out our header and footer. Our enqueued plugin scripts then, aren't ...
0
votes
1answer
272 views

Strange error from functions.php files (wp_register_script)

I'm trying to migrate a wordpress site, and I'm receiving this error when debugging on the new server: Notice: wp_register_script was called incorrectly. Scripts and styles should not be ...
0
votes
0answers
35 views

Can't change local language with function

I'm trying to add a function in my theme to change the local language for certain pages. function nfo_redefine_locale($locale) { global $locale; $locale = 'de_DE'; return $locale; } ...
0
votes
1answer
80 views

Add Element as a Filter to the_content

Can I and How would I add a filter in the function.php that would add a HTML element around the content when the_content is used? This would be similar to what you can do with the_title. i.e: ...
1
vote
2answers
194 views

How to change featured content to a different tag in Wordpress Twenty Fourteen?

In twenty fourteen theme, we’d like to know how to change the features content tag. Currently it’s set as featured. Now, we would like to know how to code this for different page templates. We ...
0
votes
1answer
46 views

Rename Default Category (Uncategorized) Via a Function

I'm looking for a function to rename the default 'Uncategorized' category. The reason I need this is because I'm running a WordPress multi-site largely used by users with little technical knowledge ...
0
votes
1answer
53 views

Wordpress theme showing blank page

Something is wrong to my installed theme, because when I am clicking on Visit Site than its showing blank page. No error and no content, no navigation nothing to display. There is link below :- ...
1
vote
1answer
79 views

Pulling Twitter RSS feed not working as expected (fatal error)

I'm trying to get some of the latest posts from a Twitter account, without a plugin. According to Botcrawl.com's tutorial, this should be enough: <ul> <?php include_once(ABSPATH . WPINC . ...
0
votes
1answer
91 views

Enqueueing a code block from an options framework

I'm currently working with the Redux Framework to allow users of my theme to add additional CSS and JS code to their theme's header and footer, respectively. Redux stores this code in a global ...
0
votes
1answer
298 views

Change custom post type slug from plugin options

I'd like to give users the option to change a custom post type slug in my plugin. Using this answer, I'm able to hardcode it into a function: Redeclare/Change Slug of a Plugin's Custom Post Type ...
0
votes
0answers
49 views

Exclude a category of posts from all listings if user doesn't have a role

I have some categories that I'd like to bulk exclude from all listings (the loop on the main blog listing page, category listing pages, archives, etc.) and to show them only to users with a specific ...
0
votes
1answer
105 views

Modify function Shortcode_atts

function get_date_posts($params, $content){ $default_params = array( 'post_type' => 'post', 'order' => 'asc', 'orderby' => ...
0
votes
1answer
152 views

How to load jQuery in the footer - nothing works for me

I tried all the solutions I found on the internet, including the ones I found here, but nothing works on my theme - jQuery always load in header. I try to use the one from Google, but I would be happy ...
3
votes
1answer
134 views

How to Loop Plugin Option Field Set?

Problem/Background Currently, I'm creating a plugin for a client that will enable them to mark and modify predetermined Google Map polygons (displayed on the site) in the dashboard. I want to let ...
0
votes
0answers
845 views

Creating custom theme options page

I am creating a theme for a client and it has a custom front page that has a slider and displays the services they offer. I am looking to add an options page where the client can easily update the ...
0
votes
1answer
72 views

edit formatting.php in a theme so it wont get overwritten

There are some parts of wpautop I want to remove, but keep the rest. I found in wp-includes/formatting.php within the function wpautop: $pee = preg_replace('|<p>\s*</p>|', '', $pee); // ...
0
votes
0answers
26 views

Creating a custom abstract/excerpt function: retrieving text between a specific tag or id

Unfortunately, the functions for retrieving the abstract and the excerpt don't fit my needs. I want to define a part in my text that should function as abstract without falling back to ...
0
votes
0answers
67 views

Cant use php fopen() function in functions.php

I am trying to simple run fopen() in the functions.php, and have also tried it in a test.php wordpress template file. But it does not work. If I move the test.php file and csv file to a location ...
0
votes
1answer
81 views

Allow tags and attributes in post and pages content

I am trying to allow the "onclick" attribute on links as well as some html tags such as iframe to the content displayed in posts and pages. In my theme's functions.php file, I tried removing ...
0
votes
0answers
58 views

Wordpress 2014 Theme - Featured Content with multiple tags?

My company is using the new 2014 Theme for our portfolio blog. We really like the Featured Content section on the home page. What we would like to do is have multiple pages all with different ...
-1
votes
1answer
428 views

Hueman layout styles and custom post type (DW Q&A)

I'm running a wp site with the Hueman Theme and the Q&A plugin from DW. The theme doesn't really plays well with the theme, so I had to find some solution for it. Managing the is somewhat painful ...
0
votes
0answers
31 views

how a query can use local parameters in plugin function?

I've wanted to add a custom post type, so i've done a plugin to put on/off this post type. i have widgets inside the plugin in order to print posts with this custom type, that call more or less a ...
0
votes
1answer
55 views

Function shortcode - Set Parameter

function get_gifts_posts($params, $content){ $default_params = array( 'post_type' => 'post', 'order' => 'desc', 'orderby' => ...
0
votes
1answer
118 views

How can I add a Custom Button to Add or Edit post / page next to Add Media?

I'm trying to add a custom button nearby the Add media on the wordpress Add and Edit Post/Page. How can I do that? Thank you very much for your help!
0
votes
1answer
29 views

search form leads to 404

I'm using the follow code in my functions.php to add a search box to my primary nav menu - add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2); function add_search_box_to_menu( ...
0
votes
2answers
70 views

Override the Wordpress core function wp_referer_field

I'd like to override the core Wordpress function wp_referer_field to change the value of $referer_field variable inside of it. I've found that wp_referer_field is not pluggable and that I need to ...
0
votes
0answers
52 views

Slider Issues using MetaBox Plugin

I'm just now joining a previously launched project. The home page slider is a custom meta_box type from the MetaBox plugin. Here is the code to add the fields. $meta_boxes[] = array( 'id' => ...
0
votes
2answers
656 views

Display Custom Field Value on Admin Page Column

What I want is to display the value of the custom field called 'page_template'. I use the code below but it displays nothing under Page Template column although I have already defined a value for the ...
2
votes
1answer
340 views

Different 'WP_CONTENT_URL' for different subsites in Multisite setup?

I host quite a few blogs on my network (WordPress Multisite) and have their static content served via a common CDN, by simply setting the wp-content directory URL in wp-config.php like so: # ...
0
votes
1answer
539 views

Add gallery id to rel attribe of wp_get_attachment_link

Now i have this snippet in my functions.php /** * Add rel to links. */ function add_rel_to_gallery($link) { return str_replace('<a href=', '<a data-fancybox="true" rel="group" href=', ...
0
votes
1answer
89 views

how to edit functions.php in a child theme

I am using wordpress for my site. I am using a theme called esplanade. I have made a child theme folder and created a style.css with the required lines in it. My child theme is working nicely. I have ...
0
votes
1answer
55 views

Is there a way to prevent a function/method from being called outside a specific hook?

I would like to make function only callable by a specific action, in this case the register_activation_hook() function. How can I do this?
0
votes
1answer
31 views

Add unique id to Preview URL

Is there an easy way to append a unique ID to the preview URL when the preview button is clicked by a user? So this: http://example.com/news/1/title/?preview=true Becomes: ...
0
votes
0answers
131 views

Update all posts in one go

I've just used the woocommerce CSV uploader to add 1000+ products to an online store. However the products only appear in the store after they have been updated - And it has to be from the main edit ...
0
votes
1answer
91 views

theme options not saving

I've created a really simple theme settings page to just enable my user to add some social media links. However when I input some data and save the fields the text vanish's and doesn't seem to save. ...
1
vote
1answer
30 views

Calling directories to load in wordpress

I have a wordpress install, with two sub folders "assets" and "functions" these folders contain important files for the wordpress theme. What would be the best way to load these files I've tried ...
1
vote
0answers
209 views

Woocommerce - sort by discount in dropdown menu - woocommerce_get_catalog_ordering_args [closed]

I have searched and searched for a solution for adding a "Sort by Discount" to the dropdown on the shop page in woocommerce. I need to add a calculation such as this somewhere: $percentage= ...
4
votes
2answers
537 views

Replacing Icons in the Dashboard

Is there a way for me to replace the icons in the WordPress Dashboard with custom ones? I'm imagining there's got to be a way to do this with the functions.php or, more ideally, with a custom-built ...
0
votes
2answers
52 views

Dequeue scripts in IE7 only using functions.php

Is it possible to dequeue scripts in IE7 only using functions.php? I have my scripts configured in the following way: // JS function scripts() { // Register scripts & styles ...
0
votes
0answers
45 views

how to echo script in head from plugin options page via textarea?

I know how to echo in the head but when i paste a script in the textbox in my options page it comes out like this: &lt;script&gt; ...
0
votes
1answer
60 views

How to change menu order item

Hello I have a main menu in my website Home | How to start | about | contact | categories but I add one item that lists all categories in functions.php add_filter('wp_nav_menu_items', ...