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.
2
votes
2answers
100 views
WP disobeys disabling of the posts revision feature
I disabled the posts revision feature according to this codex by placing this code in the wp-config.php:
define('WP_POST_REVISIONS', false );
But revions are still being saved by the WP. Why?
I am ...
1
vote
3answers
3k views
How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
I'm building a plugin and I want to add bits of javascript in the admin head but only for certain admin pages. I don't mean pages as in a WordPress page that you create yourself but rather existing ...
1
vote
3answers
370 views
How many times can I hook into the same action?
I have a theme which includes some setup, using after_setup_theme but I'd like to write my own functions which also need to run after_setup_theme. I'd prefer to keep my stuff in a separate file. Can I ...
1
vote
1answer
1k views
Is it possible to remove the main rich Text box editor?
I am using the simple fields plugin to provide additional rich text editors and have no need for this 'main' text editor box on any of my 'page's
I have tried the following code in my functions.php:
...
1
vote
3answers
366 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 ...
1
vote
3answers
651 views
Insert Ad Code in the Middle of a Post
I want to insert an ad code in the middle of a post via functions.php.
I found several links but either they don't use functions.php or don't insert the code in the middle.
Can anyone tell me how to ...
1
vote
2answers
224 views
VERY new to coding - keep breaking site trying to add to functions.php
I really appreciate everyone on this site who takes the time to answer questions here. I've learned a good deal already reading, but am sure I could learn even more if I could get past at least one ...
1
vote
1answer
1k views
Edit the_content function
I want to edit the default function the_content(). I know i can add_filter('the_content', 'with_my_function') but im having trouble outputting the old content with mine.
Heres an example of what im ...
1
vote
3answers
104 views
How to break down importing of feeds
I am attempting to update a large array of feeds into WordPress, using fetch_feeds. As can be expected, when going over 50 feeds the server is starting to time out. I would still like to update the ...
1
vote
1answer
410 views
Enqueue Javascript Correctly for 3.5
I am trying to create tabs for admin settings page in wp, but I think I'm doing it wrong. The example below shows how I did it but I don't know how to change this to use it correctly with no conflict ...
1
vote
1answer
207 views
Generating add_settings_section() calls dynamically
I have some pieces of code within functions.php that I could easly replace with much shorter functions, like, for example:
function register_sections() {
add_settings_section('SOMETHING_settings', ...
1
vote
2answers
1k views
page template for attachement page?
hey guys,
I couldn't find anything on the web. Is it possible to have custom template for the image attachement page. I wonder if it is possible to add a navigation to the image attachement page so ...
1
vote
2answers
130 views
Is there a theme function for is_password_protected()?
I'm looking at the function and template references and I'm not seeing a way to test for whether a post is protected. Is there a theme function for (something like) is_password_protected()?
I'm ...
1
vote
1answer
651 views
$user_id vs. is_user_logged_in()
I found a code scrap on the internet which uses
if($user_id) {
instead of
if ( is_user_logged_in() ) {
to check if the user is logged in. I would assume that the first would be slightly faster ...
1
vote
2answers
928 views
How to change the admin menu “Pages” to something else
When one creates a custom post type you have the ability to define various elements related to that post type which essentially allow you to define things such as the menu title, "add new post" text ...
1
vote
1answer
103 views
How to add default images into theme customizer image control?
I am trying to figure out how I can pre-load a theme customizer image control with images I have selected. Is their a way to point the control to a directory so they automatically show up in the ...
1
vote
1answer
219 views
Passing variables to templates (alternatives to globalizing variables)
I want to make my WP code simpler (there's some mess within header.php, page.php etc.). So, for example, I want to set something like this global:
$foo = get_option('foo');
So $foo will work ...
1
vote
1answer
349 views
Call to undefined function get_blog_option()
In the functions.php of my plugin I've added the following code:
function relativePathForUploads( $fileinfo )
{
global $blog_id;
$path = get_blog_option($blog_id,'siteurl');
...
1
vote
2answers
1k views
Load post with a different template?
Let's say I have a single.php file with a certain layout (graphic intensive). I want to create a sort of plain-text version of the same page that is only called when the user clicks the provided ...
1
vote
4answers
175 views
how do you create an admin interface in plugin for your theme
I'm creating a theme that would need some settings on the client side. So I need a admin interface where they can set some values. (like, source of image, title, or numbers)
so in my theme, I can ...
1
vote
2answers
188 views
Display trackbacks separately from comments in twentyeleven
How do I display trackbacks (the link and the date) outside of the twentyeleven comment loop?
The function below is from the twentyeleven functions.php file. I'm using the standard comments.php file ...
1
vote
1answer
279 views
Overiding functions.php with child-theme
I've been searching for a proper solution to override functions and hooks in my parent theme's functions.php.
My parent theme has:
define('TS_INC', TEMPLATEPATH .'/inc');
require_once( TS_INC ...
1
vote
1answer
246 views
How to determine which custom header image is being shown
I'm using a customized version of the Twenty Eleven theme. I want to set a class on the body based on which random header image is displayed. Is there some function that allows me to get the name of ...
1
vote
2answers
1k views
How do I “unhook” / de-register jQuery so that it's not called as part of wp_footer();?
I need to "unhook" jQuery from my wp_footer() ... it's being called automatically and I'm looking for something I can add to functions.php which prevents it from being called a second time in the ...
1
vote
3answers
440 views
How to add .htaccess code through a function?
I need to add the following .htaccess code through a function
<IfModule mod_deflate.c>
# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
...
1
vote
2answers
407 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 ...
1
vote
2answers
2k views
class=“parent” for wp_list_pages?
<div class="menu">
<ul>
<?php wp_list_pages('exclude=&title_li='); ?>
</ul>
</div>
creates the following output...
<div class="menu">
...
1
vote
2answers
487 views
How to add custom template tag in wordpress theme?
I am working on a WordPress site, it's an online newspaper site.
The theme I am developing, I want to add custom template functions like get_footer() or get_header(), so that I can save those HTML ...
1
vote
2answers
3k views
If category is in parent category?
I have function that check what is main top category of post. So i have category tree like this
Foo
-bar
--foobar
cat2
and if post is in foobar, my function post_is_in_descendant_category shows me ...
1
vote
2answers
219 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
vote
1answer
65 views
Does WordPress Development Mode Exist (with not minified JS)?
A lot of WP JS is minified and therefore it's hard to be analyzed in the Console. Is there any way to have all scripts uncompressed?
1
vote
1answer
67 views
Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php?
Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php? I have a mu-functions.php file in the mu-plugins folder. One function calls a javascript file (alerts.js) located in ...
1
vote
2answers
182 views
Remove double space after a period
I run a multiple author platform with more than 1000 writers. Most users writer their content externally (Microsoft Word, OpenOffice etc) and paste it into the Visual Editor. Around 20% of the ...
1
vote
2answers
67 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 ...
1
vote
3answers
221 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 ...
1
vote
2answers
250 views
the_post_thumbnail fallback using hooks
I am using this big theme that is almost entirely relying on widgets and sliders.
Now I trying to avoid looking for post_thumbnail output code in all the included files in order to achieve fallback ...
1
vote
1answer
344 views
plugins_url vs plugin_dir_url
Im seeing WordPress plugins either use plugins_url or plugin_dir_url when creating constants to some of their folders. Is one better than the other?
examples:
define( 'MEMBERS_URI', trailingslashit( ...
1
vote
1answer
252 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
3answers
519 views
get php variable from functions php and echo it in theme template files [closed]
This may seem like a silly question but I cannot figure this out.
I've created a variable in my functions.php - and I'm trying to echo it in my template files.
I'm guessing it's because of scope.
...
1
vote
1answer
783 views
Wordpress Enqueue for homepage only, functions.php, wp-framework
I'd like to replace my:
if(is_home())
{
wp_enqueue_script( 'homestuff', get_theme_part( THEME_JS . '/home.js' ), array( 'jquery' ), null, true );
wp_enqueue_script( ...
1
vote
1answer
726 views
.cycle is not a function
I'm having a problem I've never seen before. In a very new WordPress install, I uploaded a theme I had been working on for a friend's restaurant: CornerPocketPub.com
The problem, as you can see, is ...
1
vote
4answers
761 views
wrong php date()?
hey guys,
it's weird and I've never experienced that before. I've created a new blog and a custom theme. I'm using <?php echo date("H:i"); ?>in my theme.
The time that's put is 2h earlier. ...
1
vote
1answer
400 views
Toggle Sidebar Display
I'm developing a WordPress theme that allows users to toggle the visibility of the sidebars using Javascript in the same way that wikis allow users to show or hide a table of contents.
When a user ...
1
vote
2answers
978 views
post meta data clearing on autosave
For starters I am using this GREAT answer to achieve custom post types as well as a custom way to insert those post types into other pages, you can view that answer here:
Custom field/meta populated ...
1
vote
2answers
202 views
Is there a wordpress function that I can use to retrieve the current page that is loaded?
Suppose that I create a page in the admin section (under 'Pages') and I have permalinks turned on and this pages slug is 'my-new-page', then is there a WordPress function that will work outside the ...
1
vote
2answers
258 views
Run functions only in the admin area?
I'd like this code to only run inside the admin area as it is resorting the items on the public side admin bar too.
/* Reorder Admin Menu to put "Pages" at the top */
function ...
1
vote
2answers
33 views
2 Loops, Only Displaying 1 Loop in Both Loops
I have 2 loops, movie trailers and gaming trailers but gaming trailers is displaying under both Movie Trailers and Gaming Trailer. Each loop displays the post tagged with either Movie Trailer or ...
1
vote
1answer
26 views
Modifying Custom Post Type after registration (will it affect content?)
I have a CPT (defined in functions.php) that I have set to as non-hierarchical. A lot of content has already been uploaded into the database.
If I change the definition to 'hierarchical' => true, ...
1
vote
1answer
82 views
Custom Post Types relationships
I have a custom post type for my videos. I need do related it with other post category. And i have 10 category
Like this :
Post Category - Video Category
Tech Tech
Marketing ...
1
vote
1answer
68 views
plugins_url() works everywhere but wp_reqister_script()
So I should probably mention up front that I'm developing a plugin so my url is 'mysite.com/plugin' (Just in case this is related to my issue.
So, In my main plugin file (myplugin.php) I have added ...
