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
630 views

How to limit character length in BuddyPress function output [closed]

BuddyPress has a function (bp_member_profile_data) that pulls profile data into a members loop which looks like this: <?php bp_member_profile_data( 'field=Organization' ); bp_member_profile_data( '...
0
votes
2answers
239 views

Changing functions.php and .htaccess files

Can I mess up my Wordpress site if I change functions.php file for my custom theme? One time I added some code to it and it gave me some PHP errors and my site was inaccessible. Luckily it was in the ...
0
votes
1answer
212 views

Looking for Functions File that doesn't Exist

My WordPress site seems to be running fine, except that trying to go to the plugins page gives the following error: Fatal error: Cannot redeclare _verifyactivate_widgets() (previously declared in .../...
1
vote
1answer
87 views

How does Wordpress insert Paragraphs in posts

So when looking at the html-view in the editor there is no <p> tags, when a view the post every line break is surrounded with a <p>. How?
0
votes
1answer
1k views

hook for dashboard show_user_profile

I'm looking a way to avoid regular users go to profile and dashboard page. Have this little code to work with profile page: function lockdown_profile() { global $current_user; return !...
0
votes
1answer
745 views

How can I call a PHP function inside a hardcoded shortcode?

Maybe I'm doing this the long way but I need to make something like this: <?php echo do_shortcode('[mu-events months="11" startmonth="today" orderby="time" orderas="ASC" sites="?> <?php ...
1
vote
1answer
78 views

Wordpress Access allowed to fewer pages till user logs in

Is it possible in wordpress,by editing theme functions.php, to stop user access for all pages except Home, about-us, contact-us until a user is logged in to the system? All buddypress and wordpress ...
2
votes
1answer
117 views

More than one meta field in a single meta box?

I'm following this tutorial by Justin Tadlock on creating meta boxes. http://wp.smashingmagazine.com/2011/10/04/create-custom-post-meta-boxes-wordpress/ I can get a meta box with a single field to ...
8
votes
3answers
684 views

Order posts (across the whole site) by metadata date

My custom 'Home' page is set to sort my custom posts via the custom date field with this (updated to be custom named) code in functions.php: // sort order for home page add_action('wp', '...
0
votes
1answer
968 views

Uses for function: wp_update_user

my theme currently uses the wp_update_user function to update a set of user metas. I created to some new user meta fields that I would like to include in the existing wp_update_user. The function ...
0
votes
2answers
583 views

Echoing function into Wordpress NextGen gallery

Is there anyway to echo a function into a wordpress shortcode? heres my code: <div id="subscription"> <?php echo do_shortcode('[nggallery id=$ID]');?> </div> $ID is a function ...
0
votes
1answer
132 views

Why does this fail: Disabling plugins enqueue_script() in functions.php

I'm trying to use the method presented here: Restricting a Plugin to Only Load its CSS and JS on Selected Pages? In the plugin 'syntax-highlighter-compress' I've got the following code: function ...
1
vote
2answers
1k views

Theme Options: If There is No Input, Don't Display?

I have built a custom options panel which allows site owners to enter their social profiles. I then use the second code to make the links appear in the theme. When no link is entered in the options ...
0
votes
1answer
119 views

How would I make a function to dynamically determine if user is logged to change navigation menu text?

I would like to create a function to determine if a user is logged in or logged out. If the user is logged in I would like the navigation menu text to say "My Account" (this is what it currently ...
3
votes
2answers
2k views

delete post also attachments

I am trying to delete a post with its all attachments. This is the function that i came up with right now; function remove_post(){ if(isset($_POST['post_id']) && is_numeric($...
0
votes
1answer
687 views

using admin functions on frontend

I'm updating my plugin to rely on internal functions of WordPress. I'm about to use wp_generate_attachment_metadata, but this function seems to be only available in the admin section. Is there an ...
0
votes
3answers
121 views

Best way to handle lack of titles in microblogging

I'm experimenting with doing "microblogging" with WordPress and I'm doubtful about how to handle "titles" when one uses different post "formats" (the "formats" may or may not be related with the core ...
0
votes
4answers
313 views

Problem with <code> tag

Where you can see it: http://themeforward.com/demo2/functional-codes The first button is my code, as it should appear. The second button is within <pre><code></pre></code> ...
0
votes
2answers
258 views

How to make modifications only to certain elements of an HTML string on the server-side?

Is there a similar way to select / perform DOM manipulation on the server-side (PHP) like the way jQuery works? For example, if I wanted to modify content of each <pre class="raw">...</pre&...
0
votes
1answer
105 views

Wordpress comment_form() does not display actual comments

Maybe I did not understand the role of comment_form(). After pasting this in my wordpress single.php I get just the form for submitting comments but NOT THE ACTUAL COMMENTS. Is this a bug, or the ...
1
vote
4answers
223 views

Snippets: is it better to add them in functions.php or make site-specific plugins?

Should "snippets" (short code or functions) be added to: the theme's functions.php? OR make site-specific plugins? Which is better from technical, security, performance, etc., standpoint? ...
0
votes
1answer
217 views

How to call a specific value within the functions.php file?

Hi all, I'm a newb here, but hoping someone might have the answer to my question. Within my functions.php file, I have this code: //Contractor Page meta box details $contractorpage_meta_box=array(); ...
0
votes
1answer
84 views

Javascript Function Called Too Early in PHP Script

I'm working on a Google Maps plugin. My problem is that the function that initializes the map, csf_map_maker_js(), is getting called too early-- before the div is defined (at least that's what I ...
0
votes
1answer
77 views

Any adverse effects of adding apply_filters to a function?

I'm going back through my older WordPress theme and making the functions filterable and also adding the function_exists checks. Is there anything I'm not thinking about that this may cause problems ...
0
votes
1answer
815 views

Error on Include php:/usr/share/pear

I'm trying to work with an old plugin http://wordpress.org/extend/plugins/wp-ecards/ (I'm not the plugin author) and I get this error in the php error log and a blank screen when trying to view the e-...
0
votes
1answer
436 views

How do I call an external php non WordPress class into functions.php?

All my WordPress files are in: /httpdocs/news/ and the classes I want to call are in: /private/classes/ Would I use the include_once() function or is there a WordPress function? And how would I ...
0
votes
2answers
434 views

Wordpress Categories: Function using custom SQL to return array of specific category IDs

I'm developing a custom theme which uses categories for positioning, all of which begin with an underscore (e.g. _position1). I have an SQL query as below to get a list of these categories (those ...
-1
votes
1answer
202 views

Correct phph syntax to add an image in wp functions.php

as i am a newb here, please help me to get this solved. i am trying to add a function in wordprress functions.php where i am trying to display an image relevant to my theme folder here is my code ...
0
votes
1answer
100 views

How can I remove page titles without removing the link in the navigation bar in twentyeleven?

I 'd like to remove the titles from every page in my blog. But the title in de navigation balk must stay of course. Any idea? Please explain as easy as possible :-) cause I 'm taking my first steps ...
9
votes
2answers
9k views

How to change default position of WP meta boxes?

Im wondering if there is a way to change the default position of Wordpresses meta boxes such as "featured image" for custom post types without having to drag them manually? Example:
1
vote
3answers
3k views

Remove “You are using Wordpress 3.2.1” from Right Now Dashboard Widget

I'm looking for a to hide the text on the dashboard that says "You are using WordPress 3.2.1" in the Right Now widget. Not that we don't love WordPress, but for our use-case (where we'll be providing ...
-1
votes
1answer
803 views

Adminimize Plugin — Is there an alternative to limiting Editor to 'Appearance > Widgets' only?

Adminimize > Menu Options: I want to grant access to "Appearance > Widgets" only to select users (but not Themes, Editor, Add New Themes; nor Plugins, Settings). Although I have selected this in the ...
5
votes
1answer
1k views

how to group custom post types

hi wanted to know do i group my custom post types to appear together in a group in the wordpress back end menu bar like this below in the picture what code do i have to use in my functions.php so that ...
3
votes
2answers
2k views

hook a functions to change wp-config from functions.php

is there a way to hook / filter or add action that would be printed in the wp-config file? lets say i want to add some simple command like "empty the trash" aka define('EMPTY_TRASH_DAYS', 1 ); ...
1
vote
1answer
337 views

Target a certain page within wordpress backend (admin) i.e. Pages > About

How can i progammatically see if the page that is currently open in the wordpress admin is 'About-Me'; I wish to run specific functions depending on the page the user is editing in the wordpress-...
0
votes
1answer
76 views

referencing the current user in a page i created in wordpress

I created a page in wordpress and i tried to access the current logged in user via wp_get_current_user() and am getting error "function undefined". please how do I make this function available in my ...
1
vote
1answer
396 views

Query posts from category based on a filter most favorited

I have one question. I need to query posts from category based on the filter most favorited ( http://pastie.org/2751114 ) which is placed in custom_sort.php to my index.php page This is how the posts ...
1
vote
1answer
267 views

exclude category from WordPress Form function

I have this function and I need to somehow exclude a category number 14 from my submission form. Is there any way to do it inside this function? function retrieve_cat_data($byid = false){ $...
0
votes
1answer
61 views

Adding a filter to my posts

Hello guys I would like to append a link to the end of the content within my post. I currently have this in my functions.php file: function ifcj_comment_link() { global $post; return ' <a href="'. ...
0
votes
2answers
907 views

Problem with WordPress output text ('esc_html' & 'wp_richedit_pre')

I have a problem with output text. When I editing text in the WordPress control panel everything looks normal: http://i.stack.imgur.com/GaIut.png but when I output it to the html: <?php esc_html(...
7
votes
5answers
3k views

Is there any global functions.php file which works for any theme?

Is there some global kind of functions.php file that works for any theme? The problem is here: When I change a functions.php file in any theme, I need to take care of two changes: First, I need to ...
0
votes
1answer
200 views

Theme Demo in live Site

I don't know how to explain this question but let me try, Just Imagine I've a website called xyz.com and in xyz there are 10 themes uploaded and in homepage i'll show name & screenshot of all 10 ...
0
votes
1answer
63 views

Shortcode Variations?

The function below creates a button when used like so [btn]Button Text[/btn] function btn($atts, $content = null) { extract(shortcode_atts(array('link' => '#'), $atts)); return '<a class="...
0
votes
1answer
198 views

Modify code for functions.php with specific twitter user url and hashtags

I am looking to import Tweets with certain hashtags and came across this great response and coding in the link below. My question is how to just get posts from one particular twitter user and will the ...
0
votes
1answer
252 views

How to apply the 'current_page_item' class to an archive page in `wp_list_pages()`?

So I have the following custom wp-query working on my site: function custom_front_page($wp_query){ if($wp_query->get('page_id')==get_option('page_on_front')){ $wp_query->set('...
9
votes
1answer
3k views

Using classes instead of global functions in functions.php

In many themes I've seen (including TwentyEleven) and in the examples I've found online, when building the functions.php file for a theme all functionality is declared in a global scope. To clarify, ...
2
votes
1answer
1k views

Enqueuing Script in functions.php vs on the page

Does it matter if I enqueue a script on just the page I need it to be used? As opposed to functions.php? Or, what is the best practice? In this example I need a rotator just on the front page of my ...
1
vote
1answer
4k views

Targeting specific menu with wp_nav_menu_items

Hey! I have added a wp_loginout() to my header using a snippet in my functions.php: add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2); function add_login_logout_link($items, $args) {...
1
vote
1answer
103 views

custom rss templete

The objective is to fetch fields associated with a specific post id to create a custom rss feed. It is required to use functions like the_content_feed('rss2') , the_excerpt_rss() etc outside the ...
0
votes
1answer
547 views

Creating a mobile site by adding a new class to the body tag from functions.php

Essentially is there a way to use a function in functions.php to turn the <body> tag into <body class="mobile">? I have code that recognizes mobile devices but right now it's set up to ...