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

Use a function to update post meta based on other post meta

No idea how to title this so feel free to edit. I set out to create a "hotness" for my posts and to do this I used the $ratings_score which is stored as post_meta as a number +/- and the days ago of ...
1
vote
2answers
1k views

Prevent Data Resubmission On Page refresh

UPDATED FOR CLARIFICATION I've got this rating plugin that keeps submitting & duplicating the rating data on page refresh. When a user wants to add a rating, they have to click a button that ...
0
votes
2answers
932 views

Conditional custom menu?

I'm trying to create a custom menu that displays a <li></li> when a user is logged in, and not display it when they're not. I have this so far, but it's not working. Does anyone know how ...
1
vote
1answer
211 views

How to display posts by current user in a drop down

I am trying to write a shortcode that works in conjunction with Contact Form 7 to display the current user that is logged in posts. I have been able to get it to work with regular posts using this ...
1
vote
0answers
121 views

Insert a “view all ” option on wp page navi [closed]

Is it possible to/how can I add a view all function to my wp-pagenavi? For example : 1 2 3 >> View All >> Currently I just have the 1 2 3 >> but would like to give my visitors to option to 'View ...
2
votes
1answer
1k views

Apply custom role capabilities to administrator (without plugin)

I have a custom role that allows access to only a sigle custom post type. This is all well and good, but now it is only showing up for this role, not for admin and super admin. I'm having a hard time ...
0
votes
1answer
150 views

Adding a Tag Parameter / Filter to My Shortcode

I have this plugin that displays category featured image thumbnails for each post via shortcodes.. like so, [categorythumbnaillist 3] (3 being the category of course) I would like it to only show ...
0
votes
1answer
303 views

JQuery prepend a function

I am trying to see where I went wrong with this code. I was trying to prepend the avatar and user meta above the admin menu. I get header already sent messages as well since the code is just right ...
1
vote
1answer
359 views

Add custom image sizes to media uploader

I want to add custom image sizes to the media uploader: In order to do this, I use the following code (comments are there for convenience): // this function adds the custom image sizes to the ...
2
votes
1answer
144 views

New Plugin: Post update pushes a copy as a revision

I've been working alot with editing of posts after they've been published. I know I can hit update on the post to just update it, but I want to have the journey of revisions available for users to ...
0
votes
1answer
1k views

Widget update function not saving values

Hello WordPress Answers! I'm having trouble with the widget update function saving values correctly, but first let me explain the situation. I'm writing a simple news ticker widget plugin, which ...
0
votes
1answer
428 views

Fatal error: allowed memory size when after using enqueue_script

I an trying to enqueue four script files and keep getting this error: Fatal error: Allowed memory size of 103809024 bytes exhausted ... wp-includes/class.wp-dependencies.php on line 175. I used ...
0
votes
1answer
1k views

How to use wp_editor(); in functions.php then retrieve content in the template

I want to use wp_editor(); (custom editor) I've tried several methods but I am lost and I can't get it to save the post and retrieve the content in template How to edit posts with the new wp_editor ...
0
votes
2answers
216 views

Change Default Content when Creating a Post based on Previous Category Choice

I'm working on a system that forces users (unfamiliar with wp) to choose a category before creating a new post, and then adds some appropriate html layout styling to help them. The following code ...
1
vote
1answer
77 views

Execute a function using ajax

I have a function called function getSingleAmazonProduct($asin=''). It returns an amazon product. I have a form field to enter the $asin. <div id="asinform"> <form ...
3
votes
3answers
1k views

Search everything (posts, pages, tags, cpt, meta)

I would like to know how to use the built in wordpress search to return results from all content on my site. Specifically, I want to search; posts pages tags custom post type (portfolio) custom ...
0
votes
1answer
84 views

How to shorten code with function?

Now on the front page, in the part with post excerptions I have such a code: <div class="wiadPodtyt"> <ul> <?php $piwa = get_posts( array( 'posts_per_page' => 2, 'cat' ...
0
votes
1answer
531 views

AJAX function not working [closed]

One person on the site wrote a function, but I do not know why it works. This function displays a random quote. The functions implemented the ability to download new quotes via AJAX (link New Quote), ...
1
vote
2answers
192 views

Load .txt file for login_message in wp-login.php

How do I load the contents of a text file - or any other file, like .php - and use the test for the login_message hook that prints a message above the #login box in wp-login.php? (BTW, this is in a ...
1
vote
3answers
1k views

Using get_terms for custom taxonomy in functions.php

I`m trying to retrieve the names of taxonomy items and include them into a theme admin panel. function retrieve_my_terms() { global $terms; $terms = get_terms('taxonomy'); foreach ...
2
votes
1answer
1k views

wp_is_mobile function

Let me know whether wp_is_mobile function will work with all the mobile and tablet devices ? Is it enough to check mobile device ? I found that this method in wp-includes/vars.php function ...
0
votes
1answer
142 views

Replace function in a child theme

Is there a way to replace a function by another function in a child theme? In other words, in a theme there is a function named "theme_function" and this function is called by several files inside the ...
0
votes
2answers
173 views

Using locate-template & shortcodes doesn't appear to work

For organisation, I'm trying to split up the functions.php file into separate files. In particular the functions for shortcodes in a separate file, with the shortcodes being defined in functions.php. ...
5
votes
2answers
877 views

Use AJAX in shortcode

I have the following code to the shortcode to display a random quote. Question: how to make a button display a new random quote? I mean, that would hit the button and show you a new quote (without ...
0
votes
1answer
405 views

Show top commenters without using a plugin

I'm trying to create a small list of top commenters in my sidebar. I don't want to use a plugin, so I was googling for codes. All I could find was the following: function top_comment_authors($amount ...
1
vote
2answers
137 views

Remove the deleted users avatar from list

Problem Hi everyone, I have a bit of a problem. I have a function that outputs the avatars of users that follow me . It works great, but if the user is deleted the avatars remain visible as a blank ...
2
votes
1answer
983 views

Multiple Content Block

I'm trying to create a custom post type and would like that post type to have two content blocks. So that in the loop I can ask for content-1 and content-2 separately. I can write the code just ...
0
votes
1answer
453 views

Call javascript functions from each page

Is there a plugin that supports calling custom functions that you've created? Like, page A -- I want to call function x $(document).ready(function(){ call_function_x() }); page B -- I want ...
0
votes
1answer
2k views

Echo a div to header.php from functions.php

Within the section of header.php I have a div structure <div id="header"> <div id="masthead"> <div id="branding"> ... I want to add a div within "branding" - I can do this ...
0
votes
2answers
744 views

How to use the do_action () with parameter

I am trying to trigger an action in functions.php with the do_action() function, but I appear to need an attribute. The following do_action( 'really_simple_share button="facebook_like"'); does not ...
0
votes
1answer
3k views

Can't call Javascript function - scope?

I get a method not defined error when trying to call a function loaded with wp_enqueue_script from site.js. I'm guessing it's because of scope caused by the jQuery ready wrappers? How do I get ...
0
votes
1answer
193 views

function to return comma separated list of meta values

I'm customizing the admin edit.php screen and I have a column that displays a meta key $gear. But it only lists the first value instead of returning a list of all the values. Here's the bit that ...
0
votes
1answer
1k views

Set WordPress Default Template

I'm using the Options Framework Theme to put together my options page and would just like to know how would I set up/call the Default Template - for whichever one the user has selected. For example, ...
0
votes
1answer
74 views

Basics of changing plugin output

There's a Mailchimp plugin I would like to alter it's output in order to match my needs. For example: Order in which fields are loaded are not correct Positioning of the plugin's response messages ...
0
votes
1answer
291 views

The_excerpt() doesn't parse <!--more--> - how to change that?

I'm using the_excerpt(); in blog.php file (post listing page) and it doesn't recognize <!--more--> if "Excerpt" field is empty and it grabs the beginning of the content as excerpt. This issue ...
1
vote
1answer
99 views

modify a function filter

I am using the latest version of wp-ecommerce (3.89) and a new filter has been introduced to enable role based access to certain dashboard features such as the sales page or upgrade capability. ...
0
votes
1answer
602 views

Sorting custom post types in edit.php : Post disappear

I've got a few custom post types with different taxonomies and I have a function that adds certain categories to post list view in edit.php admin screen. Everything good there. I've also added a ...
1
vote
3answers
430 views

Delete post revisions on post publish

Is it possible to delete post/page revisions from the database when a post/page is published? 11/05/12 Answer: See the plugin below by bueltge I want to do this on a site with 5,000 posts and ...
4
votes
2answers
901 views

Build a content and excerpt grid loop with paging and options for # of posts

What I'd like to do: on index.php, a loop that shows a selectable number of full posts using the_content and then below that shows a selectable number (the number of posts can be hardcoded in the ...
2
votes
4answers
5k views

Why isn't is_page working when I put it in the functions.php file?

I have page called "Apple", the page's ID id 2533. In page.php file I have line: echo $bannerimg And this function in functions.php: if ( is_page( '2533' ) ) { // also tested with ...
0
votes
2answers
978 views

Remove theme, change theme button and WP version on “Right Now” admin dashboard?

I am looking for a way to remove theme, change theme button and WP version from the "right now" admin dashboard, but using only functions. Any help?
1
vote
2answers
2k views

Change date number to another language/script?

I previously was able to change the numbers of the date and time (into a number and date system of another language, like Khmer) for each post using a script like this in my functions.php: function ...
0
votes
2answers
321 views

Getting RID of thickbox!

I want to get rid of the complete thickbox css js and loading gif. Can anybody give me the correct way to get rid of it all via functions.php ? Cheers, Alex
0
votes
1answer
177 views

Migrating site, only header shows

I have copied my file structure to a new server, and exported the relevant tables to an SQL file. I have imported the tables to the new database. When I visit the new URL, only the header of the ...
0
votes
1answer
114 views

does acf_save_post cause endless loop?

I am using Advanced custom fields acf_save_post hook in one of my functions. In that function I use the add_post_meta function. Does this call acf_save_post again and cause an endless loop? ...
3
votes
1answer
3k views

How to edit bbPress template files - WordPress + BuddyPress + bbPress? [closed]

I am using BuddyPress 1.6.1, bbPress 2.1.2 and WordPress 3.4.2 I follow the guide here. In the end, I did the trick pointed out by Sarah Gooding because mywebsite.com/forums was blank right after ...
0
votes
2answers
2k views

is there a way to remove featured image from blog page and single page

<?php /* * * The default template for displaying content. Used for both single and index/archive/search. * * @package WordPress * @subpackage Twenty_Twelve * @since Twenty Twelve 1.0 */ ...
0
votes
2answers
228 views

Auto-Tweet if Type is 'Status' using OAuth

Should be simple - I'd like WP to tweet the content of a post once (when it's published the first time) if the post format is 'status'. The code below isn't returning an error on publish, nor is it ...
3
votes
1answer
308 views

Restrict users from editing post based on the age of the post

How can I restrict users (based on Capabilities) from editing their published posts after a custom amount of time. For instance, a user that can publish_posts (authors) can not edit a their post if ...
0
votes
1answer
216 views

display custom portfolio tags

This is a part from the code that is used to display portfolio categories: $post_cat = array(); $post_cat = wp_get_object_terms($post->ID, "portfolio_category"); ...