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.

Filter by
Sorted by
Tagged with
4 votes
1 answer
7k views

How do I make my function add variables/values to the $post object?

How do I add $tzDesc and $tzEmbed (and other variables) to the $post object in the following function so that I can display the values in my theme files by inserting <?php echo $tzDesc; ?>? ...
matt's user avatar
  • 1,652
0 votes
1 answer
539 views

Update users custom profile fields

Ok guys, i have problem when using some trics from here or other sites. Im trying to use this method of adding custom user fields. But, when i add this, everytime i save its all ok, but when i come ...
Саша Стефановић's user avatar
3 votes
4 answers
7k views

Forcing all posts associated with a custom post type to be private

Does anyone know of a way to add code to the functions.php file which will automatically force all posts belonging to a custom post type to be "private" and/or "password protected" with a default ...
NetConstructor.com's user avatar
1 vote
3 answers
700 views

Insert all post IDs in new database table

I have a plugin which creates a new database table. Upon activating the plugin is there a way to insert all my posts ids into that table? Right now I'm using an action hook to immediately insert the ...
wpStudent's user avatar
  • 141
2 votes
4 answers
2k views

wp_enqueue_script + how to load JS or CSS in one URL merge call?

Is there any proper wordpress way of including the JS and CSS through one merged URL? So that instead of loading in x number of separate calls for each JS asset, it can be all merged into one URL? ...
AndreLiem's user avatar
  • 121
1 vote
2 answers
300 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. ...
wpStudent's user avatar
  • 141
-1 votes
1 answer
14k 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 ...
user avatar
0 votes
2 answers
577 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', ...
wpStudent's user avatar
  • 141
1 vote
1 answer
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 ...
wpStudent's user avatar
  • 141
0 votes
1 answer
2k 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 ...
Dave Hunt's user avatar
  • 1,085
1 vote
1 answer
3k 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 ...
wpStudent's user avatar
  • 141
3 votes
1 answer
637 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 ...
NetConstructor.com's user avatar
0 votes
1 answer
2k 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 ...
wpStudent's user avatar
  • 141
1 vote
3 answers
303 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?
NetConstructor.com's user avatar
2 votes
2 answers
2k 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 ...
NetConstructor.com's user avatar
2 votes
1 answer
506 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=...
user1147's user avatar
  • 802
2 votes
1 answer
500 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" ...
Scott B's user avatar
  • 5,666
1 vote
1 answer
129 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 ...
user avatar
1 vote
2 answers
359 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 ...
Scott B's user avatar
  • 5,666
0 votes
1 answer
440 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.
user1147's user avatar
  • 802
2 votes
1 answer
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?
gillespieza's user avatar
  • 1,275
1 vote
1 answer
260 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; ...
Scott B's user avatar
  • 5,666
2 votes
1 answer
693 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 ?
user1147's user avatar
  • 802
1 vote
1 answer
1k 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
user1147's user avatar
  • 802
9 votes
8 answers
46k 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 ...
curtismchale's user avatar
  • 2,599
0 votes
1 answer
373 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 ...
Zolomon's user avatar
  • 115
2 votes
1 answer
118 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?
jnthnclrk's user avatar
  • 1,825
2 votes
3 answers
683 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 ...
Norcross's user avatar
  • 3,077
1 vote
1 answer
1k views

How often is functions.php loaded?

Trying to get my head round functions.php and am wondering how often it is loaded?
jnthnclrk's user avatar
  • 1,825
4 votes
2 answers
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?
user1327's user avatar
2 votes
1 answer
3k 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 ...
NetConstructor.com's user avatar
6 votes
2 answers
4k 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 ...
NetConstructor.com's user avatar
0 votes
1 answer
156 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, ...
fxfuture's user avatar
  • 1,337
0 votes
3 answers
2k 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 ...
NetConstructor.com's user avatar
1 vote
1 answer
122 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 "...
MTT's user avatar
  • 3,546
3 votes
1 answer
7k 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 ...
phwd's user avatar
  • 223
1 vote
2 answers
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). ...
NetConstructor.com's user avatar
7 votes
4 answers
7k 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 ...
NetConstructor.com's user avatar
346 votes
108 answers
168k 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 ...

1
111 112 113 114
115