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

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.

1
vote
2answers
263 views

greatest() function returns undefined property

I'm using the mysql GREATEST() function to compare two table fields and display in a loop either one with the highest integer value. The 2 fields consist of vote scores for posts: UP or DOWN. ...
-1
votes
1answer
8k views

simple wp_insert_post example

i've spent way too much time trying to use the wp_insert_post() function a <form> and i do not know why it is not working. // Create post object $my_post = array( 'post_title' => 'My ...
0
votes
2answers
395 views

Check if variable is set in filter

Thanks to your suggestions, I enabled wp_debug and discovered flaws with my plugin. I have a filter for sorting posts by votes. I use it when the sort URL parameter is on. add_filter( 'posts_where', ...
1
vote
1answer
2k views

Missing argument 3 for wp_register_sidebar_widget()

I installed the Deprecated Calls plugin and it's telling me to change register_sidebar_widget() and register_widget_control(), essentially add wp_ first. I did but I'm getting Missing argument 3 for ...
0
votes
1answer
1k views

Adding Pages to Menus - No Page Hierarchy in Backend [duplicate]

Possible Duplicate: How to add a custom metabox to the Menu Management admin screen? In the backend of Wordpress, under Appearance -> Menus it allows you to add different post types by clicking ...
1
vote
1answer
2k views

add_query_arg not working

I added a filter to append a parameter onto the URL when navigating in categories. This is used to sort posts by their votes when browsing a category only if a sort parameter is set. For instance ...
3
votes
1answer
623 views

Roles & capabilities GUI that does not create separate table

After reviewing plugins that deal with user roles and capabilities I concluded that I might be better off just hardcoding my settings into my functions.php file. This actually worked out well for me ...
0
votes
1answer
1k views

SQL error with custom query

I'm trying to create a custom post query for sorting posts that have been voted "thumbs up". I'm joining my custom "wp_post_votes" table (which stores the number of votes each post received) with ...
1
vote
3answers
292 views

Default menu editor with automatic page list

How can I add a page to the menu and define for the menu item that all subpages should be included by means of a simple checkbox?
2
votes
2answers
818 views

How to let a single post have its own domain name

I am not sure which solution here would work best as a solution but what I am looking for is just a simple way to enter an optional domain through a metabox on the page edit screen and then just ...
2
votes
1answer
480 views

Wordpress change author email notify message?

just want to change a little bit author email notify message(wp_notify_postauthor - pluggable.php),and I'm applying filters on comment_notification_text function myfunction(){ return "<div class=...
2
votes
1answer
481 views

How to list all images in uploads directory except those that are attached to any post

I've got code in my functions.php which parses the WP uploads folder and lists all images it finds there. Is it possible to place a filter here that would exclude any image that is already "attached" ...
1
vote
1answer
122 views

Author Tracking Code!

I need help with coding this piece. Basically i want with someone click on my author page. It stored a cookie of that author name and email. I want the cookie to stay in place untill the person close ...
1
vote
2answers
253 views

How can I add a CSS rule to edit.php?

I'm using add_filter('manage_posts_columns') in my plugin.php to add a column to the Edit Posts listing which is driven by edit.php. How can I attach a CSS style to the edit.php? I want to be able to ...
0
votes
1answer
417 views

Add array of post id's to a category?

Is there a function to add array of post id's to a category,something like this array(2,3,5,6) to put in some category,not looking for update post. Tnx in advance.
2
votes
1answer
2k views

How do I display a tag cloud with both post tags AND a custom taxonomy?

Using wp_tag_cloud(), how can I display a single tag cloud that incorporates both regular post tags and a custom taxonomy?
1
vote
1answer
216 views

Function returns different value when called from 'save_post' than when called on page load

The "word_count" function below returns different values depending on where its called from. Why? add_action('save_post', 'my_custom_save', 10, 2); function myPlugin($post) { global $rockScore; ...
2
votes
1answer
655 views

Set user loggin status?

I create user with wp_create_user,after succesfully creating a user I need to set his status to be logged in?How to set his status to be logged in ?
1
vote
1answer
880 views

How to pass data from page to widget functions?

I need help,need to pass data from page,to widget function,I need to pass author id to widget,any idea? Tnx
8
votes
7answers
26k views

Include files in child theme functions file

Typically in my theme function file I'll require other files to keep things neat. require_once("foo.php"); Now working in a child theme I'd like to do that same. I'm adding custom admin options and ...
0
votes
1answer
365 views

Get urls of images in a gallery?

I need to retrieve the URLs for the images inside a gallery, what's the appropriate SQL query for this, based on the post ID? I currently have something like the following which I found on via ...
2
votes
1answer
107 views

Should everything in functions.php be hooked or filtered?

Considering how often functions.php is called, shouldn't all of its contents be hooked or filtered into core WP functions like init?
2
votes
3answers
597 views

Link Category Description

I'm pulling my hair out over this. In the Links manager, you can enter a description for the category (in addition to the link itself). However, in wp_list_bookmarks, there is no way to call this ...
1
vote
1answer
746 views

How often is functions.php loaded?

Trying to get my head round functions.php and am wondering how often it is loaded?
4
votes
2answers
3k views

Enabling Sessions in WordPress 3.0

Im using a wfcart in my WordPress site but for some reason on certain pages WordPress drops the session I'm wondering if there is a way to enable sessions in WordPress 3?
1
vote
1answer
2k views

Help extending custom drag-drop page ordering on admin page list screen

I am utilizing the following code which transforms any hierarchical page or custom post type with the ability to reorder the the pages through simple drag/drop. (also this code also adds a new display ...
6
votes
2answers
3k views

How to add a custom metabox to the Menu Management admin screen?

Although I am very thankful to the wordpress core team that they have finally integrated native menu management capabilities I get frustrated with some key elements which I would like to change. I ...
0
votes
1answer
145 views

Defining the value of a variable before a function?

I'm trying to edit a plugin so that it only shows it's submenu if the user is an administrator but I don't know how to define the value of the variable before the function: function load_view( $name, ...
0
votes
3answers
1k views

Removing Unnecessary Text from Admin Menu without CSS

I am looking for a way to remove all the unessesary text from default worpdress metaboxes. Preferably I would like to ensure that the content is not just hidden through CSS but actually removed from ...
1
vote
1answer
99 views

How to display html in only the first level of WP comments?

How would I display html code in only the first level of threaded comments? Example L1 Comment ----L2 Comment --------L3 Comment L1 Comment I have a piece of html code that contains basically reads "...
2
votes
1answer
4k views

register_post_type for Pages?

Been reading this site and Wordpress Codex and I see there is a function to enable custom type of pages in Wordpress. How can I do the same to enable for Pages ? Or at least get the options for the ...
1
vote
2answers
1k views

Using Default WordPress Custom Header Image Crop Feature in a Post Type / MetaBox

I am not sure how many of you have experimented with the new custom header image functionality of wordpress 3.0 but its actually very cool (enabled by adding the function to your functions.php file). ...
7
votes
4answers
5k views

Removing Metabox for “Slug” without removing functionality

Here is an interesting question. I have recently noticed that if you utilize the code remove_meta_box('slugdiv', 'post', 'normal'); you are actually unable to modify the slug when you click on the ...
324
votes
108answers
151k views

Best Collection of Code for your functions.php file [closed]

Please vote on the question and any answers you find useful by clicking on the UP arrow on the left hand side of the question or answer. As with many others who are now viewing this post, I have been ...