Skip to main content

Questions tagged [php]

For questions about the server-side programming language that the WordPress core, plugins and themes are written in. Questions about using PHP outside a WordPress context are off-topic but might be asked on Stack Overflow.

2 votes
2 answers
1k views

Comment filtering (search)

Basically I want to develop the ability to search comments on my site. A form with input field where the visitor can enter a search string, which tells WP to display only comments that contain that ...
Alex's user avatar
  • 1,081
0 votes
2 answers
478 views

Custom Slider Per Page created

I am developing a site that will need to have a slider with 4-8 images, but only on certain page-types. These pages must be editable and the sliders must be able to be updated whenever I'd like. I ...
wilwaldon's user avatar
2 votes
2 answers
8k views

How do I make wordpress comment fields required?

Here is my form: <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform" class="validate"> <?php if($user_ID) : ?> <?php ...
danixd's user avatar
  • 181
3 votes
1 answer
2k views

Get the sidebar ID in which the current widget was dropped

How can I find out in which sidebar was a widget dropped? From inside that widget. More precisely from the form() function. Can I automatically remove the widget if it's not added in the appropriate ...
Alex's user avatar
  • 1,081
2 votes
1 answer
417 views

Count widgets of a certain type

How can I get the number (count) of, let's say, text widgets from a sidebar? for eg. if I drop 4 text widgets in the sidebar, I want to get this number somehow from another widget
Alex's user avatar
  • 1,081
1 vote
1 answer
174 views

A function that returns true when the Author is a certain role is_author(admin)?

I need a function that returns true when the author is an admin or an editor or of a certain role. I can't use is_single because I have set up a forum and there are a million singles out there and I ...
user avatar
1 vote
1 answer
617 views

How do I let users upload files to a chosen location?

I found some plugins which let me make my own forms but none worked for different reasons. I simply want to make a form so that users can upload files to a folder located in www.chusmix.com/images ...
user avatar
1 vote
1 answer
405 views

How can I show the post thumbnail from the most recent of a certain post type, in widget?

I'm using the excellent PHP Code Widget plugin, and want to create a widget that displays the post thumbnail (aka featured image) for the most recent 'project' post. Here's the code I have so far, but ...
Travis Northcutt's user avatar
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
2 votes
2 answers
3k views

Why does this echo values in the wrong order?

I'm sure there is a simple reason/answer for this: Why does echo 'Archive for '. the_time('Y'); give me 2010Archive for? I had expected it would give me Archive for 2010
gillespieza's user avatar
  • 1,285
1 vote
3 answers
707 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
0 votes
2 answers
579 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
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
2 votes
1 answer
238 views

WP database error for comments_popup_link()

I'm using the comments_popup_link() function to show the number of comments for each post in a loop. <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php if ( ...
wpStudent's user avatar
  • 141
6 votes
2 answers
9k views

Preserve custom URL parameter on more pages

I created a custom URL parameter for sorting posts by their vote scores. I have a "most voted" link that sends a ?sort=most_voted URL paramater and using a query posts filter I display posts with most ...
wpStudent's user avatar
  • 141
1 vote
1 answer
531 views

Fastest way to get the comment and ping total count for a post

I'm making my own comment template (like this) and I need to know how can I get the comment and ping count for the current post, maybe using a fast database query or something like that? Note that I ...
Alex's user avatar
  • 1,081
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
0 votes
2 answers
1k views

Custom query_posts() parameter

I'm adding voting features to a theme. Visitors can vote posts Up or Down. I created a table for storing number of votes for each post and that works fine. Now I'm trying to sort posts by their votes. ...
wpStudent's user avatar
  • 141
1 vote
1 answer
230 views

Prevent WordPress from loading comments

I'm displaying the comments for a post my way, using $comm = get_comments() and then passing $comm to wp_list_comments() (this is the reason why). How to disable WordPress from loading comments from ...
Alex's user avatar
  • 1,081
2 votes
2 answers
2k views

Getting $comments outside the comment template

I have a ajax request hooked on "template_redirect" (the ajax requests the post's url), and I want to display only the comment template: function get_comm(){ if(isset($_GET['get_my_comments'])): ...
Alex's user avatar
  • 1,081
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
1 answer
5k views

WP_Query with the "offset" argument

I'm making a custom query for posts using something like: $p = new WP_Query(); $p->query(array('offset' => 30, 'posts_per_page' => 10)); If I have 36 posts on the entire blog, $p->...
Alex's user avatar
  • 1,081
2 votes
3 answers
887 views

where to include a php file

I have a php file with some variables which I would like to use. When I include it in the header.php the variables in that file are not recognized at footer.php and some other places. Where is the ...
Ofer's user avatar
  • 23
6 votes
4 answers
8k views

How to load and show comments with AJAX instead of pagination?

Is there a plugin that displays comments like this: http://img541.imageshack.us/img541/6541/47905634.jpg when the user clicks "read more", older comments are being appended to the list with ajax.
Alex's user avatar
  • 1,081
2 votes
1 answer
2k views

if statement on database query

Part of a voting script I'm working on: I'm checking a custom table in my WP database to see if a user already voted for a post by checking the IP address and the post id. If the user's IP already ...
at least three characters's user avatar
0 votes
1 answer
2k views

add_action for publish_post doesn't work

I'm working on a personal voting plugin, I don't intend to release it publicly because I'm still learning WP. In general, you can vote posts "up" or "down". I have 2 tables, one collects IPs (to ...
at least three characters's user avatar
1 vote
1 answer
491 views

Custom post type - get_day_link()

How can I get the archive links for a custom post type? get_day_link() doesn't seem to work
Alex's user avatar
  • 1,081
0 votes
1 answer
333 views

Remove problem PHP code entered into footer via Theme

A friend of mine has a WordPress site using the Theisis theme. Recently he added a bit of problematic PHP code to the footer via the Theme (not into a PHP file). The PHP code is erroring out causing ...
Chaulky's user avatar
  • 103
1 vote
1 answer
232 views

Missing sidebar parameter "fix" - before_content

as you know the sidebar parameters from register_sidebar() that control the widget layout are - before_widget - after_widget - before_title - after_title the problem is that you cannot implement ...
Alex's user avatar
  • 1,081
2 votes
3 answers
198 views

Recent comments from my blogs only

I'd like to create a list of recent comments, specific to each user on my network (Buddypress). My best idea so far is pretty lame: DB Query on all user's blogs, compare dates, select top 10 by date. ...
konzepz's user avatar
  • 268
1 vote
1 answer
190 views

How can I reuse the code to capture a param in a URL and place in a value in a hidden form?

I have a form that will be re-used in different posts. I also have php code that will be reused to populate the form with the value in the URL. I tried to use php shortcode and wp php exec, but it ...
satchel's user avatar
  • 143
0 votes
1 answer
6k views

Fatal error: Call to a member function query() on a non-object

In the code below (from my functions.php), I'm attempting to create an array of items from the wp_postmeta table where the meta_key is "_wp_attached_file". I'm getting an error: Fatal error: Call to ...
Scott B's user avatar
  • 5,696
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,696
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
1 answer
724 views

problems with wordpress and php version 5.3.3-1

I recently installed a server with new php version - 5.3.3-1 and when I imported wordpress site and database, there were some problems with plugin settings - some of them were reset. In pagenavi ...
banesto's user avatar
  • 153
5 votes
3 answers
5k views

Need help with friendly URL's in Wordpress

I'm creating som custom templates in Wordpress and I'm passing some data in the URL's. Currently my URL looks like this: http://www.mysite.com/designers/?id=43&name=designer+name The URL ...
Steven's user avatar
  • 2,610
0 votes
2 answers
1k views

Strip tags from a the terms() function

Trying to print my custom post type's taxonomy but without the link. Tried this, but doesn't seem to work, any suggestions? $text = the_terms($post->ID,'type','','',''); echo strip_tags($text); ...
pete_schuster's user avatar
4 votes
1 answer
3k views

difference between esc_attr(), strip_slashes(), strip_tags()?

So what's the difference between these, and when should we use each one? Is esc_attr() safe enough to escape any type of data you get from the user ?
Alex's user avatar
  • 1,081
4 votes
4 answers
3k views

Enable/disable post revisions programmatically

Is there a way to temporarily disable revisions.... I have noticed that wp_update_post is very slow and creates revisions I don't need. The fix could be to disable revisions before issuing ...
Riccardo's user avatar
  • 961
0 votes
1 answer
3k views

Horizontal drop down category with hover effect working

It will be difficult to explain what I need in words, so please see a live demo of the horizontal navigation menu here, http://cn.wsj.com/gb/index.asp I want to replicate it for wordpress categories. ...
RichZenMaster's user avatar
1 vote
2 answers
245 views

Using wordpress template tags within an array

A bit of a noob PHP question coming up. I am trying to create a generic archive style view for my custom post types. Ideally I want to create one generic template that can be used for all post-types. ...
George Wiscombe's user avatar
2 votes
1 answer
914 views

Display All Post Attachments and Assign Class to the Last Image?

I have a function get_images() in which I would like to display all image attachments for the current post (or page) in a list with the last image having a class="last" attribute to mark it as the ...
Scott B's user avatar
  • 5,696
2 votes
3 answers
2k views

I can't view or add comments

Hey, there. I just got this site up and going. http://www.paledogstudios.com It works fine except for the fact I can't seem to see past comments (this blog was imported from blogger) or add comments. ...
nalem's user avatar
  • 23
3 votes
1 answer
5k views

Wordpress multisite causing Error 101 (net::ERR_CONNECTION_RESET): Unknown error [duplicate]

Possible Duplicate: WordPress upgrade now receiving Error 101 (net::ERR_CONNECTION_RESET): Unknown error We have just installed WordPress 3.0.1 and everything worked fine. However, as soon as we ...
Alex's user avatar
  • 161
2 votes
1 answer
3k views

Admin-ajax.php appending a status code to ajax response

I'm writing a plugin that uses Ajax (jQuery with form plugin) via a form submission and the php function returns a JSON response. add_action( 'wp_ajax_bubbly-upload', 'bubbly_upload_submit' ); ...
jjeaton's user avatar
  • 2,187
2 votes
1 answer
3k views

Adding graphics to 404.php page

I am trying to customize the 404.php page by adding a graphic. I can figure out how to change the text and links, but the HTML I just don't know well enough to add a picture or graphic. I am using ...
Marc's user avatar
  • 21
1 vote
1 answer
365 views

want to create a subcategory.php to manage subcats

Is it possible to create a subcategory.php and use it to manage subcategories? Or is there a way to get around this? If it is not possible.. is there something like this? <?php if(is_subcategory(...
andrewk's user avatar
  • 171
5 votes
3 answers
8k views

How to set custom cookies before output

What's a surefire way to check/set cookies before the php headers are sent? Is there an action or filter that would be the best place to hook a setcookie() function?
Dan Gayle's user avatar
  • 6,136
2 votes
2 answers
11k views

How can I get the page or post language when I use wpml? [closed]

I'm using WordPress MultiLanguage Plugin and I want to know what is the language of a specific element, page or post. I do have the id but I want to obtain the language.
sorin's user avatar
  • 1,123

15 30 50 per page