INSTRUCTION
stringlengths 11
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
next_post_link on custom taxonomy
I want to use `next_post_link` and `prev_post_link` to return only the next post in my custom taxonomy of a custom post type. I have a custom post type called "work_posts" which has the taxonomy "work_categories" assigned. The category I want to show is called 'all'. I looked up `get_adjacent_post` in the "link-template.php" which has a few filters which should make it possible to make such a query but my SQL is not good enough to make the right query. The hooks are:
* `get_{$adjacent}_post_join`
* `get_{$adjacent}_post_where`
* `get_{$adjacent}_post_sort`
if I log a query in the join hook I get:
INNER JOIN wp_term_relationships AS tr
ON p.ID = tr.object_id
INNER JOIN wp_term_taxonomy tt
ON tr.term_taxonomy_id = tt.term_taxonomy_id
AND tt.taxonomy = 'category'
AND tt.term_id IN (3)
how do I modify this to only show posts from my custom taxonomy?
|
Take a look at < Its a plugin that adds extra missing functionality to next_post_link and prev_post_link functions.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "custom post types, custom taxonomy"
}
|
2 small questions: How to redirect to a created page & show that pages title in wp, bp
im trying to redirect the loggedin user to a page i created on the backend, i want to use my index to do so
so, i added a `do_action` wrapped in an if statement `is_user_loggedin()` to call my function.
here's the function:
function my_redirect() {
global $bp;
if ( $bp->current_component == $bp->root_domain ) {
bp_core_redirect($bp->current_component == MY_CUSTOM_SLUG );
}
}
but it's not working. The page shows when you navigate to it, but it wont redirect when viewing the root page (index).
Here's whats in the index.php
<?php if ( is_user_logged_in() ) : ?>
<?php do_action( 'my_redirect'); ?>
<?php endif; ?>
Thanks ahead of time :)
|
I think what you're trying to do here is create a custom hook. You should just do this to make it work correctly:
<?php if ( is_user_logged_in() )
my_redirect(); ?>
There's no need to make it an action if you can use the function directly in your template. Actions are primarily used when you want to alter the behavior of core or you don't want to alter an already existing template.
Since you're creating your own template anyway, just call the function directly to reduce overhead. I would do this before get_header() or any characters are rendered or you will receive a PHP error.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, functions, buddypress"
}
|
Conditional Tags for Membership Levels when using Wishlist Member Plugin?
I am currently using a plug-in called Wishlist member. It allows you to create membership levels in WordPress. I want to be able to display different content on a page depending on the membership level of the viewing user. Something like this -
<?php global $current_user; get_currentuserinfo();
if ($current_user->user_level == 10 ) { ?>
Admin Stuff (In my case I left this blank)
<?php } else { ?>
Stuff Seen By Visitors
<?php } ?>
But not just for the admin. I have found that this plug-in create creates these for each member level "wpm_access[1296320588]" and "wpm_level[1296320588]". Any ideas on how I could check the current user against this?
Thanks!
|
there is a lot of discussion about this in wishlisMembers support forum but the developers over there ignore it. Any way try this:
// get the current user level from WP more important is global $user.
$user = wp_get_current_user();
// Get user levels from WishlistMembers
$levels = WLMAPI::GetUserLevels($user->ID);
//then run the check for the level you want like this:
if(in_array('silver', $levels)){
// PRINT OUT THE silver LEVEL stuff here
}
elseif (in_array('gold', $levels)){
// PRINT OUT THE gold LEVEL stuff here
}
Simple.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 2,
"tags": "user roles, membership"
}
|
Why can't I query more than 1 post type at a time?
I have a custom post types called **publications**. I want to retrieve all the **pages** and **publications**. (I'm also filtering by taxonomy, but that's not what is creating the problem)
$args= array(
'post_type'=>array('publications', 'page')
);
query_posts($args);
The above only returns pages, not publications. If I remove 'page' from the array and leave
'post_type'=>array('publications')
then the publications are returned.
Its seems like I cannot query more than one post type at a time, contrary to what the codex explains here.
I've tried `'post_type' = 'any'` with the same results; only the pages are returned. Using `WP_Query` also yielded the same results.
Am I doing something wrong or is this a bug in WP 3.1 rc3?
|
Hi **@Bundarr:**
Testing the following basic example as a standalone file it looks like it works as expected and not as you are reporting:
<?php
include '../wp-load.php';
header('Content-type: text/plain');
$q = new WP_Query(array(
'post_type'=>array('publications', 'page')
'posts_per_page' => -1,
));
echo "SQL: {$q->request}\n";
foreach($q->posts as $post) {
echo "{$post->post_name} - {$post->post_type}\n";
}
So, I can only assume that you have some plugins or theme code that is somehow blocking?
Or maybe it is as simple as missing a `'posts_per_page' => -1` argument and thus only displaying a limited number and making it seem like it's not working? With `'posts_per_page'` the query would look like this _(-1 means 'no limit'):_
$q = new WP_Query(array(
'post_type'=>array('publications', 'page')
'posts_per_page' => -1,
));
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "custom post types, query posts"
}
|
Proper implementation/use of code/syntax highlighting
I've already read what I can on a couple of sites and installed this plug-in:
<
<
I'm missing how to make it work. Now I have two questions:
1. Do I have to type in the Visual window or the HTML window?
2. Does TinyMCE mess with this? I've seen my code disappear in the HTML window.
I currently have typed in my code in Visual Window like this:
[sourcecode language="php"]
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: );
if ($_GET["page_id"] == 1)
Header( "Location:
if ($_GET["page_id"] == 2)
Header( "Location:
?>
[/sourcecode]
I also tried `<pre language="php">` with the "Geshi" syntax highligher, and no luck there either.
But nothing is happening, i.e. no syntax highlighting: <
|
I use a similar plugin called WP Syntax, which works better, in my experience, so I'm going to answer for that one:
> Question 1: Do I have to type in the Visual window or the HTML window?
In the HTML window. I prefer the `<pre lang="php">` mode.
> Question 2: Does TinyMCE mess with this?
Yes, it will html encode special chars, for example transforming `=>` into `=>` etc. so you should probably disable the rich editor alltogether.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "code, syntax highlighting, plugin syntaxhighlighter"
}
|
Is it possible to list and create custom post types with Vimpress?
I just started using vimpress. I can write posts by typing in Vim
:BlogNew
and send them by typing:
:BlogSend
I think a lot of Wordpress developers may be using the plugin.
So my question is Is it possible to list and create custom post types with Vimpress?
|
simple and short. up to vimpress latest version 0.91 which was developed at 2007-07-13 no you can't.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "custom post types"
}
|
Is there a filter for enqueue script to strip the type="text/javascript" property
`script type="text/javascript"` is optional in HTML5 and all browsers (even old ones) recognize JavaScript without it. I am building an HTML5 site and want my script output to be consistent. However, scripts that use the WordPress enqueue function are printed with`type="text/javascript"`.
CSS is also printed with `type="text/css"`, which is also not needed.
I can't find a filter to remove those properties. Is there one?
|
This is hardcoded in `WP_Scripts->do_item()` method ( source ) and probably same for styles. So it cannot be filtered.
As alternative you can extend class with modified version of this method and replace instance in global `$wp_scripts` variable.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 1,
"tags": "theme development, wp enqueue script, html5"
}
|
Showing Post Counts of One's (Author) Own in the admin post list
How can I show user's post counts of one's (Author) own in the admin post list (edit.php) instead of all post count of the system? like published (10), Draft (5) ... of his own or logedin user.
Thanks in advance.
|
Have a look here for the solution (code needs optimizing, but it works): Help to condense/optimize some working code
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "admin, query posts, author"
}
|
Two-way synchronizing of a post type among multisite blogs
Is it possible to two way sync a post type between multiple sites on a multisite install? For example if someone makes a change to an entry under post type "inventory" on Site A how can I make that reflect on Site B automatically and vice versa?
I am thinking that there are two main possible way of doing this, neither of which I'm sure can easily be done.
1) A plugin hooks into the edit_post so when a change is made the plugin edits the sister entry in the other blog's database table.
2) Anytime Site B views or edits an "inventory" post type it is reading it from Site A's database table.
|
I don't know what you mean by sync users. Users are global in the network and can be assigned to any blogs.
"both their public website and backend both use their own multisite blog. "
This doesn't make sense. Can you clarify?
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "custom post types, multisite, import, export, sync"
}
|
How to best create a jQuery Slider to display a native wordpress gallery?
It seems there must be a plugin for this, but I can't find it. I'd like to enable a jQuery slider in a post, using the images I've added to the gallery for that post. Does anyone know of a plugin?
And if not, what would be the smartest way to implement this? Again it's important that it calls from that posts gallery - using the native WordPress gallery.
Thanks in advance!
|
I have written a couple tutorials on how to make a dynamic jQuery featured post slider with Wordpress, here is my best one which is the most popular post on my site, in case you're interested in trying it out.
<
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "plugins, jquery"
}
|
Echo current custom post type
I have a all my custom post types list together in blog format. What I'm trying to do is echo the post type name on each post.
I tried this:
get_post_type_object('post');
echo $obj->labels->singular_name;
But it just displayed "Post" for everything instead of the custom post type name
|
If you are within The Loop, try:
$post_type = get_post_type( $post->ID );
echo $post_type;
Does this work for you?
|
stackexchange-wordpress
|
{
"answer_score": 18,
"question_score": 2,
"tags": "custom post types"
}
|
Wordpress for a club website -- Members page
I'm making a website for a student activity and have a wordpress page for each member under a common parent group. Each page contains some member info (currently unstructured) and a profile picture.
I would like to list all these members under a member page with perhaps a grid of profile pictures and names. Is there a plugin that can accomplish this?
Note that each member does not have a wordpress account. I already found plugins that can do that, but it's not what I am looking for.
|
You might consider create a custom post type `'person'` to mirror your user and then you'll be able to create member pages by creating a `single-person.php` theme template file. This answer provides code for doing that:
* **Commenting in user profile page?**
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "plugin recommendation"
}
|
Find out when a user was created and display varied content depending on time since creation
I am looking to display different content after a user registers. Is there a way to find out the registration date and then if it's been 1 day display one thing, but if it's been 2 days display something else?
Something like this, but based on the registration date and not a post entry date:
<?php if (strtotime($post->post_date) > strtotime('-30 days')): ?>
//Text for posts created in the last 30 days
<?php endif; ?>
|
Yes you can!
<?php
get_currentuserinfo();
$user_data = get_userdata($user_ID);
$registered_date = $user_data->user_registered;
if (strtotime($registered_date) > strtotime('-30 days')){
//Text for users registered in the last 30 days
}
?>
hope this helps
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 2,
"tags": "users"
}
|
Creating tags via API
I'm working on using the WP API to insert posts via AJAX.
What's the proper way of adding tags dynamically to a custom post type? These tags would not be predefined, but rather be created on demand by the user.
Currently I'm doing this:
$tags = explode(" ", $_POST['post_tags']);
$new_entry = array(
'post_title' => $_POST['post_title'],
'post_content' => $_POST['post_content'],
'post_status' => 'publish',
'post_author' => $current_user->ID,
'post_type' => 'customposttype',
'post_tags' => $tags);
$created = wp_insert_post( $new_entry );
(Yes, this is prototype code and I'm not sanitizing input yet :))
|
Hi **@James:**
If you have the post ID of your newly created post _(the`$created` variable from your question)_ you use the `wp_set_object_terms()` function, for example:
wp_add_post_tags($created,'My First Tag');
wp_add_post_tags($created,'My Second Tag');
wp_add_post_tags($created,'My Third Tag');
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "custom post types, tags, api"
}
|
Making oEmbed work on the excerpt field
How can I make oEmbed work on the excerpt field so I only have to paste the youtube url in there and then be able to echo 'get_the_excerpt()'?
I also want to filter oEmbed and change the wmode but I think I found a solution for that here: <
EDIT: Crap! I was wrong, it doesn't work at all, nothing happens. Anyone got a better solution?
|
Not entirely sure it is supposed to be used like this, but by analogue with `the_content` try this:
add_filter('the_excerpt', array($wp_embed, 'autoembed'), 9);
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 2,
"tags": "excerpt, oembed"
}
|
How to close wpdb connection?
Is there any method to close connection similar to `mysql_close()` for `wpdb` in WordPress? Is it not necessary to close connection for global `wpdb`?
|
WP 4.5 had introduced `wpdb->close()` method to close connection in current instance.
* * *
Old answer
~~There is no explicit method. It stores link identifier in`$wpdb->dbh` field, but it is protected, so not convenient to run close on.~~
|
stackexchange-wordpress
|
{
"answer_score": 8,
"question_score": 4,
"tags": "database, wpdb"
}
|
How to get events using multiple custom meta fields?
I need to grab a list of current events. The events have a start and end date so I need to be able to select a range as opposed to just getting any list of events that have an end date that is after today's date.
Does anyone have any suggestions as to how to do this? (from what I've read there doesn't seem to be a way to use multiple "meta_key" and "meta_compare" values, but there must be a way some how)
Here's an example of what I'm using in my arguments, but I need to also do this for the start date as well:
'meta_key' => 'end_date_value', 'meta_compare' => '>', 'meta_value' => $todaysDate,
|
You can use your current code to create the query and then in your loop run a check before displaying the events something like
<?php
query_posts('meta_key' => 'end_date_value', 'meta_compare' => '>', 'meta_value' => $todaysDate);
while ( have_posts() ) : the_post();
$post_custom = get_post_custom($post_id);
if ($startDate < $post_custom['start_date_value']){
//your loop here
}
}
?>
keep in mind that this is not well coded way to do this ,I would probably create a better sql query or use "posts_where" hook.
but its a start
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "query, comparison, custom field"
}
|
Anyway to assign custom post types to a specific category?
Is there anyway to assign all new posts that have a custom post_type to a specific category? For example, say I have a post_type that is for Actors. Is there anyway to assign any post that is under Actors to a "People" category? (but without displaying the Category box in the WordPress Admin)
|
you can first remove the category meta box from Actors post type edit screen like this
function remove_custom_taxonomy()
{
remove_meta_box( 'categorydiv', 'custom_post_slug', 'side' );
}
add_action( 'admin_menu', 'remove_custom_taxonomy' );
then create a function that will add the category on save_post
function default_category($post_id){
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check for post type
if ('Actors' == $_POST['post_type']) {
$Default_category_id = '23';
wp_set_post_terms( $post_id,$Default_category_id , 'category', ture );
}
}
hope this helps
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 2,
"tags": "custom post types, categories"
}
|
wp_update_term: How could i update the "name"?
I was just looking at wp_update_term and haven't found any possibility to update the "name" of the term. My scenario is pretty simple: I got some predefined taxonomy terms in a config file like this (just an example):
$taxonomy_terms = array(
'taxonomy_a' => array( 'term_a', 'term_b', 'term_c' )
,'taxonomy_b' => array( 'term_d', 'term_e', 'term_f' )
);
Now i'm trying to update these terms based on their id. So if the id exists, i change just the name.
But here does my problem start: wp_update_term doesn't offer any possibility to update the name of term... Does anybody know of some work around, or do i just oversee something?
Thanks!
|
According to `wp_update_term()` in Codex you pass fields you want to override in `$args` argument, try passing `name` in there?
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 2,
"tags": "terms"
}
|
How to delete orphan attachments?
I've been given the directive to "retire" about 1000 articles from a wordpress site I maintain. Deleting the posts from the DB is trivial, but how would one go about deleting the orphaned files from the uploads folder?
|
Try plugin called 'Media Cleaner'. It's seriously made (the author, tigroumeow, mention 5+ time "do a backup before use") + upload Janitor was last time updated 10 years ago.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 2,
"tags": "attachments, uploads"
}
|
Large WP 3.0 menu times out and won't save
I have a large menu containing 10 parent items with roughly 7 child items each that I am trying to build using the WP-admin > Appearance > Menus.
I have nearly all the menu items added but now my wp-admin backend won't save the menu, it keeps timing out and just ending on a blank screen.
I have about 4 more items left to enter but I can't save the menu anymore.
I have tried increasing the php memory in wp-config.php by adding define('WP_MEMORY_LIMIT', '64M');
but it made no change.
Any tweaks or tips to help me get this menu saved, this is the only thing holding the site up and the client is waiting.
Thanks very much! maikunari
|
You can always try to **split your menu into 2 separate menus** and then just display them next to each other in your theme. It's far from perfect and doesn't help a bit in understanding the root of your problem but it could help.
_You can use it as temporary workaround to GTD before deadline and then dig deep into memory issues or whatever causes your trouble..._
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 4,
"tags": "menus"
}
|
Listing Category 'child_of' by slug rather than ID
I want to list categories belonging to a parent. The problem is using category id's isn't useful and makes things harder to understand.
Is there any easier way to list categories belonging to a parent, similar to the default way supplied in the WP codec?
<?php wp_list_categories('child_of=8'); ?> //what category is '8' ?!
<?php wp_list_categories('child_of=clients'); ?> //much nicer, but doesn't work
I would prefer to avoid using another query in the loop, but to make sense to other developers, I might have to.
|
You can get ID from slug quite easily:
$category = get_category_by_slug( 'clients' );
wp_list_categories('child_of='.$category->term_id);
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 4,
"tags": "categories, page template"
}
|
Does set_transient() overwrite/update transient option with same key?
Basically that's the question - I wonder if `set_transient()` overwrites/updates a transient option with the same key?
|
Yes, key (prefixed with string identifying it as transient) is used as option name when value is inserted in database.
|
stackexchange-wordpress
|
{
"answer_score": 7,
"question_score": 5,
"tags": "updates, transient"
}
|
get_the_term_list without links in 3.1
What function will display custom taxonomies associated with a post as text?
I'm currently using get_the_term_list which works great for a singular page but not so much when using a taxonomy in the archive-postype.php permalink title tag.
|
wp_get_object_terms() returns the terms associated with an object (eg a post or a page or custom post) as text (normally in an array).
From the Codex page for wp_get_object_terms()
`$productcategories = wp_get_object_terms($post->ID, 'productcategories');`
|
stackexchange-wordpress
|
{
"answer_score": 18,
"question_score": 18,
"tags": "custom taxonomy, customization, terms"
}
|
Text after more tag in posts
Hey, is it possible that i can put a chunk of code somewhere and it will show up after the more tag seperator but within the post ?
I mean if i put more seperator after first paragraph then on post areas after that will show up the code i will put.. probably some html with a twitter and rss link.
Help is appreicated :) cheers Ayaz
|
This will add your code after the `more` tag area on the post page:
add_filter('the_content', 'adds_block');
function adds_block($content) {
if (is_single()) {
// return $content;
global $post;
$thePostID = $post->ID;
$test = '<span id="more-' .$thePostID.'"></span>';
return str_replace($test, ads(), $content);
}
}
function ads(){
return 'Your Custom Code,,';
}
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "posts, read more"
}
|
Category links including all posts
Really rusty on the wordpress front.
I am using custom permalinks `/%category%/%postname%/` as well as the `WP No Category Base` plugin, so my urls look like this: <
I only have an index.php set up at the moment, with the most basic loop possible:
<?php if (have_posts()) : ?>
<?php query_posts(); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post">
<?php the_title(); ?>
<br />
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php else: ?>
<?php endif;?>
The problem is, all posts are coming through, instead of just the posts in the category represented by the url. I didn't think I needed a custom query, because the link that took me to the particular url should have been carried across. What am I missing?
|
The `<?php query_posts(); ?>` in your code is causing the global query to be reset to show all posts instead of the one set by your rewrite rules. You should remove that line.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "loop"
}
|
Category specific themes?
My client wants to implement a special appearance to each of our category pages. Kind of like child themes... she wants to shift the background image, change a few graphics, and tweak the colors according to which category the user is visiting (horror, romance, etc).
Is there a reasonable way to do this besides creating a different template for each page with imported CSS styles? Or is that really the only path to accomplish this?
**UPDATE:** The answers below are all great. For our purposes, the easiest thing to do was to use the category specific classes provided by "body_class()" to override current styles.
Thanks!
|
If changes do not require modifications to HTML markup you can accomplish that by loading conditionally additional CSS style files. See Conditional Tags > A Category Page and `wp_enqueue_style()` in Codex.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "theme development, categories, plugin recommendation"
}
|
Customizing 1 theme for multiple blogs in a multisite setup
I just converted a site to a multisite setup using WordPress 3.0.4. One thing I found in a hurry is that if I wanted to edit a theme's code, the changes would be reflected on all the subsites that use the same theme. Is there a to customize the code so that only a certain subsite receives the changes??
|
If it is just css customizations, use this plugin: <
It's what wp.com uses for their css upgrade.
If you have to edit the php, make a copy of the theme with a new name on the theme folder and in style.css.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "themes, multisite, customization"
}
|
Amazon.com intergration with WordPress?
Wanted to know if there was any documentation or plugins that allowed a site to pull prices and other information from Amazon.com on DVD's and other products. I'm creating a plugin that stores information about DVD releases and I would like to create code that pulls the price from Amazon, and calculates the difference compared the MSRP and of course provide a link to the Amazon page for purchase. I do know that much of Amazon's API revolves around the product's Amazon ID number, so I know I'll have to story it with the custom post type associated with the release. Has this been done before?
|
You're looking for something a little more advanced than a simple affiliate integration. Unfortunately, I don't thing there's an existing plug-in solution for the kind of interaction you're trying to achieve. That said, it should still be possible.
A cursory search turned up Amazon's Product Advertising API, which seems to be exactly what you'll need. It provides directly programmatic access to the Amazon product database, meaning you can find (and cache) product information and prices fairly easily.
You can use this to power a local search of the Amazon database for products or just retrieve information specific to a product based on a known Amazon ID. It's up to you, and I encourage you read through the documentation and see if this is the right platform.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "plugins, custom post types, plugin development, custom field"
}
|
Good tools for locating hooks in a wordpress page/admin interface/blog post?
I've recently started using the Hikari Hooks plugin for Wordpress as it seems to allow you to get a good idea of what do_actions are being called on the page, so that you can easily find out where potential hooks for plugin code might lie.
Are there better tools/plugins for accomplishing the same thing?
In particular I was looking for one that might notify me of post status transition actions such as new_to_publish and draft_to_publish...It appears that Hikari Hooks does notify you of such changes but not that they are available, only if you're already added them as an action.
|
It is usually easy to find most hooks in documentation or source. It can be much more tricky for hooks that are dynamically generated, like post transitions. Essentially it doesn't exist in source as specific hook - it is hook that is getting generated dynamically at runtime, depending on variables.
do_action("${old_status}_to_$new_status", $post);
do_action("${new_status}_$post->post_type", $post->ID, $post);
At local test stack I often just add `var_dump()` on variables to source code to see what is going on. Dirty, but easy and fast. Obviously highly not recommended for production environment.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "plugins, plugin development, hooks, actions"
}
|
Locked out of my own blog and password reset not working
I have my own Wordpress installation for my infrequently updated blog.
I have a habit of forgetting my password so have to request a new one and reset it every two to three months.
I've done it again today and got the "Password Reset" e-mail (which arrives within seconds of requesting it). Following the link to actually reset the password gives me the "Check your e-mail for your new password." page but that e-mail never arrives.
I've checked my spam folder and there's nothing in that.
What's the quickest way of resetting my password and getting back into my blog? Do I have to go via the database? If so what do I need to reset there?
I should add that the blog hasn't been hacked - I've checked the pages and they're all OK. No spurious links or content vandalised.
|
If you can get to phpMyAdmin (or something equivalent), open the DB and find the wp_users table. Select the appropriate user to edit and change the user_pass field to `whatever`. Set the function to MD5 and save. You should now be able to log in.
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 1,
"tags": "email, password"
}
|
Secure Server after configuration
Recently I purchased a VPS from intovps.com, And first time I configured a fully unmanaged VPS through ssh comands. My website is working into it, properly. Now I just want to know how to secure it?
I started my process of configuring VPS in this way:-
Installed LAMP, phpmyadmin, restored the backup(wordpress & mysql), installed vsftpd for ftp access, added a user into FTP(user can navigate into any directory over the entire VPS, but change anything)
Now after everything, I just want to know the security steps for my VPS. I have heard from my friends that after configuring a VPS, it also needs to be configure for security. In VPS, I have only one user added for ssh access, which is default,and I just added one ftp user.
Now I want that the ftp added user should just navigate to the `/html` directory, where my website is installed, and has all writes to change everything
And any suggestions or tricks or steps for making server more secure?
|
Have a look at this excellent **question and answers** on Server Fault that discusses how to secure your LAMP stack.
Make sure your FTP user can only access the directories you want.
Setup sudo to allow a non root user to run commands as root. Lock down your ssh so that root cannot log in set
`PermitRootLogin = no in /etc/ssh/sshd_config`
Enable passwordless public key login for ssh. Disable ssh password login
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "security, vps"
}
|
Include jQuery (or anything) inside Custom Options Panel's <head> tag
The title pretty much explains exactly what I'm trying to do. If someone could help me out, that would be awesome. Thanks!
:)
|
the correct way to include files for scripts you can use the hook "admin_print_scripts"
and include your scripts with wp_enqueue_script()
for example:
<?php
add_action('admin_print_scripts','my_scripts');
function my_scripts(){
wp_enqueue_script( 'jquery' );
}
?>
and for styles use the hook "admin_print_styles" and include you styles with wp_enqueue_style
for example:
<?php
add_action('admin_print_styles','my_styles');
function my_styles(){
wp_enqueue_style( 'myPluginStylesheet', WP_PLUGIN_URL . '/myPlugin/stylesheet.css' );
}
?>
Hope This Helps.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "theme development"
}
|
Filter custom posts with / without comments
I need to display (for pages that use a particular page template) a list of custom post type objects filtered into 2 sets - those with comments, and those without comments. Each of these sets should display the last 10 of its type (ie the latest 10 posts with comments, and the lastest 10 posts without comments)
What's the best way of achieving this? So far, the easiest thing I've come up with is to just do a custom select with $wpdb. Hooking the query and adding a posts_join / posts_where filter doesn't seem like the best answer, as it's too global.
|
And I should have done some searching before asking.
Looks like hooking the query might be the best way of doing this. Here's a good answer from StackOverflow with practically the same question.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "comments, query posts, filters"
}
|
Wordpress 3.0 Multisite - Child sites and backends appearing blank
I've just installed wordpress on our Rackspace server - I've set wordpress up for Multisite as I have done many times before.
The main wordpress site at the root functions fine - however when I add a new site and click on either 'backend' or 'visit' I get 'page not found'.
Pages in the main site seem to work fine with the default permalink settings but not custom such as /%category%/%postname%/
I think this must be a server issue but am a bit stumped.
Any suggestions appreciated!
|
Yeah the server is not reading the htaccess file properly.
may need AllowOverride FileInfo Options in the httpd.conf file for that vhost.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "multisite, url rewriting, redirect, urls"
}
|
How to create a wp admin page (for use in an ajax request)
How can I create a URL to an admin page (under /wp-admin/) that I'm not adding to the navigation? I want to use the URL for an ajax request.
|
Hey, changed my google search terms and found my answer. :)
<
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "wp admin, ajax"
}
|
How to get a value for admin css color either gray or blue
I want implement theme option which will have two css files.
Example, if current admin set their profile to blue color I want load blue css for the theme options.
if (current-value-css-admin)
load blue
else
load gray
Let me know how do I get current data for the wp admin color.
|
This can be retrieved with `$color = get_user_option('admin_color');`, just don't forget to check for empty return and default to something in that case.
Native color schemes are called `fresh` (grey) and `classic` (blue).
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "css, theme options"
}
|
Is there Photo Categories?
I'm developing a theme, and there's a section for awards & certifications which will consist of just 4-6 small logos. Is there a way to put these images in a category and then display all of these images on the homepage with a simple code so the client won't have to go into the source code?
Thanks.
|
Technically you can't put images in category, because they are not posts by themselves.
1. You can create Custom Post Type for your images, etc, etc (might be overkill in your case).
2. Personally I like to use Links for such stuff. It is ready-made, easy to add images to (just URL), supports own categories and can be flexibly displayed, with wp_list_bookmarks() or widget.
I did a post on such usage of links while back - Make use of Links in WordPress.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "theme development"
}
|
Comment Reply javascript
I am working on a client site which is a very stripped down theme. It has no standard html markups as a result of which the reply box doesn't move upto the place of being just below the comment to which you hit the reply button. Can anyone point me to the minimum markup required? I am trying to add classes one by one.
**Trying to explain it better:** I click on the reply button, the page reloads and the comment form stays below all the comments list. I want it to make it work like when we click on reply button, then without any page reload, it jumps up there and can be cancelled back to the place. The default what we have in Twentyten
**Update:** I managed to fix up the markup and now I am using comment_form() but cancel reply button doesn't appear and I am not filtering that out. Any ideas?
**Done** So sorry to trouble everyone here. The last issue was fixed by removing the CSS `display:none;` ( Lesson - DIY Themes sucks unless its what you do! ;) )
|
You should really use comment_form() instead of rolling your own.
Still, if you must, make sure that:
1. The textarea has id="comment".
2. The wrapping container around the entire comment form (probably a DIV) has id="respond".
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 5,
"tags": "comments, javascript, html"
}
|
get images from post and make a zip
here is what i have so far.
function zip_gallery()
{
global $post;
$images = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_mime_type' => 'image', ));
if ($images) {
$save = $post->post_title;
$zip = new ZipArchive;
if ($zip->open($save . '.zip', ZIPARCHIVE::CREATE) === true) {
foreach ($images as $image) {
$file = wp_get_attachment_url($image->ID, 'full', false, false);
$filename = pathinfo($file);
$zip->addFile($file, $filename);
}
$zip->close();
}
}
}
can someone shed some light on what im doing wrong.
|
`ZipArchive->addFile()` method expects local path to file, while `wp_get_attachment_url()` returns URL. You need to build local path for file from URL or in other way.
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 4,
"tags": "images, gallery"
}
|
How to get WordPress Time Zone setting?
Can someone tell me how to get the time zone that is set in the WordPress Admin?
For example, if the blog is set to Eastern time, I need this exact string to print out:
> US/Eastern
This is for a function that lives in functions.php in my theme.
|
if you need the gmt_offset then
`<?php echo get_option('gmt_offset'); ?>`
this will give you an integer like **2 or -2**.
and if you need the timezone string use
`<?php echo get_option('timezone_string'); ?>`
this will give you a string like **America/Indianapolis**
|
stackexchange-wordpress
|
{
"answer_score": 94,
"question_score": 64,
"tags": "php, date time, options, timezones"
}
|
How to control Facebook share information for the front page?
Is there a way to prove information to Facebook so I can control what the title and description information is that comes up when pasting the front page of my blog on facebook?
Right now, it seems to grab a random post... not the latest... for th information. I'd prefer to either set the information myself for the front page OR insure that it shows information from my 1st/featured post.
How can I get control over this?
(again, this isn't related to a "like" button, or anything... but posting the root URL straight to a Facebook status. Sharing the whole site, not a post.)
|
Have you tried adding the Open Graph metadata?
<
I think that should give Facebook the right hints.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "facebook"
}
|
Moving Share Buttons from a Plugin
I'm using the Share and Follow plugin on my site. I like it for the most part, but the "interactive share buttons" - the ones that appear at the front of the post - are on the first line of my post. This might be OK, except that it shoves the images that are at the beginning of the majority of my posts out of alignment (on both my main page and individual posts). I would much prefer that the buttons appear under the title, but before the first line of content in my post. But because it's a plugin, I can't figure out how to change where the buttons appear.
|
Since it's a plugin you probably don't want to edit it directly as then it will revert every time the plugin is updated. It looks like the problem is that the style has a float:left on it.
<div style="float:left; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; " class="interactive_left">
If you remove that float:left you get exactly what you want. Unfortunately for you the style is inline instead of part of a style sheet so I think your only option might be to find that bit of code in the plugin and edit it directly. You could ask the plugin author to move it to a stylesheet to make that easier but it's really up to them.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "plugins"
}
|
wp_schedule_event will it run if timestamp has passed?
I've been told by my clients that scheduled jobs are not run some times as expected. I never questioned myself about how wp_cron actually works, I thought it was kinda self-explanatory. But now I doubt it.
Codex says that timestamp argument is:
> the first time that you want the event to occur. This must be in a UNIX timestamp format.
I know that wp_cron triggers events when someone visits the site. But what if the visit happens little bit after the time hardcoded in timestamp? Will that event still trigger? Or pass?
|
Yes, the event will trigger when the wp-cron process gets run. If something is preventing wp-cron from running, then it won't trigger at all. If you're having it not work, then something about your server configuration is preventing it from working.
For these cases, you can generally work around them by adding this define to your wp-config file:
define('ALTERNATE_WP_CRON', true);
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 3,
"tags": "timestamp, wp cron"
}
|
Check if SEO plugin installed
Is there any way to check whether the user has an SEO plugin installed, so as if they do not I can insert my metas etc.
|
Hi **@Liam:** ,
What you are going to need to do is create a list of the top SEO plugins and themes and then document how each implements meta and develop a strategy for each. And/or maybe you can ask your users upon activation if they are using an SEO plugin much like Akismet asks users to enter an API key.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "plugins, seo"
}
|
Change order of custom columns for edit panels
When you register a custom column like so:
//Register thumbnail column for au-gallery type
add_filter('manage_edit-au-gallery_columns', 'thumbnail_column');
function thumbnail_column($columns) {
$columns['thumbnail'] = 'Thumbnail';
return $columns;
}
by default it appears as the last one on the right. How can I change the order? What if I want to show the above column as the first one or the second one?
Thank you in advance
|
You are basically asking a PHP question, but I'll answer it because it's in the context of WordPress. You need to **rebuild the columns array, inserting your column before the column you want it to be left of** :
add_filter('manage_posts_columns', 'thumbnail_column');
function thumbnail_column($columns) {
$new = array();
foreach($columns as $key => $title) {
if ($key=='author') // Put the Thumbnail column before the Author column
$new['thumbnail'] = 'Thumbnail';
$new[$key] = $title;
}
return $new;
}
|
stackexchange-wordpress
|
{
"answer_score": 41,
"question_score": 30,
"tags": "wp list table"
}
|
Multiple users – only allow them to manage their own terms for custom taxonomy when logged in
How can I allow each user to manage their own terms for a custom taxonomy when logged in on edit-tags page? user will only show & manage terms that only created by him not others for a custom taxonomy. But Admin and editor can manage all. How can I do that?
Any help will be appreciated. Thanks.
|
Thanks for the AWESOME solution MikeSchinkel :D
I just did the following updates in the code and it worked like a charm:
add_filter('list_terms_exclusions', 'yoursite_list_terms_exclusions', 10, 2);
function yoursite_list_terms_exclusions( $exclusions ) {
$currentScreen = get_current_screen();
if( current_user_can( 'my_custom_capability_assigned_to_specific_users' )
&& !current_user_can( 'manage_options' ) // Show everything to Admin
&& is_object( $currentScreen )
&& $currentScreen->id == 'edit-<my_taxonomy>'
&& $currentScreen->taxonomy == '<my_taxonomy>' ) {
// Get term_id's array that you want to show as per your requirement
$terms = implode( ',', $term_id );
$exclusions = ( empty( $exclusions ) ? '' : $exclusions ) . ' AND' . ' t.`term_id` IN (' . $terms . ')';
}
return $exclusions;
}
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 3,
"tags": "custom taxonomy, taxonomy"
}
|
Load scripts only for selected template
Is there a built in function to load scripts only for particular template?
At them moment I am doing like so:
if (is_page('portfolio') || is_page('gallery')){
wp_register_script('jScrollpane', get_bloginfo('stylesheet_directory') . '/js/jquery.jscrollpane.min.js');
wp_enqueue_script('jScrollpane');
}
and it works as long as I call the pages "portfolio" and "gallery". I would like to have it more reusable, how can I achieve that?
Thank you in advance
|
You can use `is_page_template('template.php')` and just replace template.php with your template name.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "wp enqueue script"
}
|
Manage custom menu for an Editor?
I've a problem with permission. Is there a specific permission to let an user with Editor Role, manage the custom menu of a theme, and _only this options?_
The item that is under Appereance -> Menu, to be clear.
I'm using the capability plugin. Must I write a custom hook to enable only the use of custom menu editor ?
TIA
Edit: I've code a simple solution. See below my answer!
|
You need to give the editor role the 'edit_theme_options' permission, but that will also unlock other theme options like widgets to those users.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "menus, permissions"
}
|
How to load a template without it being assigned to a page/post?
Can I create a template and load it without associating a page/post to it in WordPress? The template will list custom posts in XML.
[update]
I have a jquery carousel that loads an XML file through ajax. I am storing each slide as a custom post type call 'carousel_slide'. I want to create an XML feed with these custom post types.
At first I created the feed outside wordpress, including wp-load.php and using WP_Query. This worked fine but I now realize that I need a multi-lingual plugin (WPML) to be loaded as well. This is why I want to create a wp template instead. However if I create a template, I need to assign a page to it to be able to load it. I'd rather not create an empty page simply to be able to call a template.
I am new to WordPress development and might have overlooked an obvious solution.
|
The basic answer - you can easily load template (or any PHP file really) with _*drumroll*_`load_template()`. :)
As for best way to implement your custom feed, I think it would make sense to do it by analogue with native WP feeds. You register feed name and handler function with `add_feed()` and load template in that handler.
Example:
add_action('init','custom_feed_setup');
function custom_feed_setup() {
add_feed('custom-post-type-xml', 'custom_feed_template');
}
function custom_feed_template($input) {
load_template('whatever');
}
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "custom post types, page template"
}
|
Allowing an email as the username?
Is it possible to allow people to utilize their email as their username?
|
As far as i know it should be possible to login with your email with wp 3.1, which will come soon.
Using an email as username is already possible. "@" and "." are allowed characters for usernames. Hope that helps.
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 5,
"tags": "users, user access, user meta, username"
}
|
How to prevent apostrophes and quotes from appearing in permalinks?
I'm using custom permalinks "/%category%/%postname%/". Whenever a post title contains quotes or apostrophes they appear in the URL.
Can someone tell me how prevent them from appearing in the slug?
I am running WordPress 3.0.4.
|
In WordPress, "---" and " -- " become em-dashes (-- `—`) and "--" becomes an en-dash (-- `#8212;`). The sanitize_title_with_dashes() function doesn't catch these.
That function uses the databased copy, but the title displayed to the user always goes through a texturize function. So if we replace en/em dashes on their way into the database, the net result will be the same and avoid these bad URL cases the titles are re-texturized.
add_action( 'title_save_pre', 'do_replace_dashes' );
function do_replace_dashes($string_to_clean) {
# The html entities (– and —) don’t actually work but I include them for kicks and giggles.
$string_to_clean = str_replace( array('—', '—', '–', '–', '‚', '„', '“', '”', '’', '‘', '…'), array(' -- ',' -- ', '--','--', ',', ',,', '"', '"', "'", "'", '...'), $string_to_clean );
return $string_to_clean;
}
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 5,
"tags": "permalinks, slug, urls, title"
}
|
How to add or delete default value theme options while activate and deactivate theme
I want to add & reset default value for my theme options while activate and deactivate a theme
More clearly something like this
if(theme active)
add_option();
// add new option to the theme and register default setting for one time only
if(theme deactivate)
delete_option();
// reset current option and delete default setting for one time only
Question
How know is theme active or not? What a function or hook for this one. Let me know
|
I think what you are looking for was answered here:
* **Theme Activate Hook**
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "functions, hooks, theme options"
}
|
SEO images in Nextgen Galleries
I have a couple blogs / wordpress sites that I post pictures on. I have noticed that most of the pictures I post with the nextgen gallery plug in never show up in google images search. Is there a way to fix this?
|
Have you filled out the "alt" tags properly. The chances of being indexed are less if the tag is not included. Additionally, the file name for the image should not be "quor7b.jpg" unless it's a photo of a Quor7b. The file name should also reflect the image (e.g. rose.jpg).
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "images, seo, plugin nextgen gallery, google search"
}
|
Can I dynamically create a link to my plugin settings/options page from my plugin description?
Currently, in my plugin description, I'm hardcoding...
> To customize options <a href="options-general.php?page=my-plugin-admin.php">click here</a>
Is there a dynamic method to call the plugin options page?
|
You're looking for a plugin settings link that's dynamically generated.
This would be one approach.
<
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 2,
"tags": "plugin development"
}
|
Changing RSS title link to link to feed instead of blog
Frustration!
Is there an easy to change the RSS title link using the RSS widget to link to the feed instead of the blog itself? It can't be this hard..
I could easily hard code this but I want to keep it as modular as possible.
|
I don't see any easy way in source.
That link is retrieved from feed by SimplePie method and is not passing through any deliberate filters. And it gets concatenated with rest of title after that is passed through filter, not before.
The only idea I have is to filter it in `esc_url()` function at `clean_url` hook, but that will only work nicely if link is unique and won't break elsewhere... Or will take some messy hook juggling to target it precisely.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 2,
"tags": "rss"
}
|
Add custom field automatically to custom page types
I have a custom page type set up called 'Products' and I need each of these post to automatically have multiple custom fields to set up a table of features/prices for the individual product pages.
Is there any way this can be done? Thanks.
|
I too had a question about this. Luckily, Chris_O answered it for me. You may also want to check out this question, too.
Here's an example of what I've done with meta boxes and you can see it's quite easy.
!Example Post Type
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "theme development"
}
|
Non-Closing PHP Query in WordPress Loop
I have the following query in WordPress to call custom post meta, everything is working fine, with one exception, whichever query is second is echoing nothing. Sorry for the WordPress post, but for those unfamiliar the '`get_post_meta($post->ID`' is retrieving the post ID for the first one and then echoing the same for the second, I need to close the first query but don't know how.
<h3 class="body_heading">
<?php $soon_events = get_post_meta($post->ID, 'coming_soon_events', true); if ($soon_events) : echo $soon_events; endif; ?>
</h3>
<h3 class="body_heading clear">
<?php $feat_events = get_post_meta($post->ID, 'featured_events', true); if ($feat_events) : echo $feat_events; endif; ?>
</h3>
|
Try `<?php wp_reset_query(); ?>` after each function. See Function Reference/wp reset query « WordPress Codex
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "php, custom field, post meta, multi language"
}
|
Custom query for custom post_type
I need to display a list of current tasks. Each task has a custom post_type and a start date and end date.
Can someone tell me how to modify my query so it will pick up any tasks that have a start date in the past and an end date in the future? (There's another meta_key named 'end_date')
Here's my query:
$todays_date = time();
$args = array ('post_type' => 'tasks',
'meta_key' => 'start_date',
'meta_compare' => '>',
'meta_value' => $todays_date,
'orderby' => 'meta_value'
);
$tasks = get_posts($args);
The problem with the query above is that it's showing tasks that in the future, but haven't started yet.
|
change your query a bit:
$todays_date = time();
$args = array ('post_type' => 'tasks',
'meta_key' => ''end_date,
'meta_compare' => '<',
'meta_value' => $todays_date,
'orderby' => 'meta_value'
);
$tasks = get_posts($args);
and then for each one of this posts get the start_date meta and compare with $today something like:
$today = strtotime($today);
foreach ($tasks as $task_post){
$start = strtotime(get_post_meta($task_post->ID, start_date, true));
if ($today > $start){
//to task stuff here
}
}
Hope this helps.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "custom post types, query, get posts"
}
|
Capability for allowing user to post own comments without moderation
I work at a radio station that has several WP user roles -- for simplicity sake, let's say Admin, Programmer, Subscriber, in decreasing order of ability.
Currently, Admin users need to approve comments left by Programmer users. How do I auto-approve Programmer-level comments, without letting that user level administrate comments globally?
Thank you!
|
Role Approved Comment plugin < This plugin will allow any specified role to have their comments automatically approved.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 2,
"tags": "comments, capabilities, user access, user roles, moderation"
}
|
Broken category pagination
For some reason the below code works until I hit the third page and gives 404. Is it possible to fix it without using any plugins?
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query('cat='. $id .'&posts_per_page=4&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<?php get_the_content() ?>
<?php endwhile; ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<?php previous_posts_link( __( 'Previous', 'themename' ) ); ?>
<?php next_posts_link( __( 'Next', 'themename' ) ); ?>
<?php endif; ?>
<?php $wp_query = null; $wp_query = $temp;?>
|
Try creating a new instance of WP_Query and at the end use wp_reset_query(); like this:
<?php
$my_query = new WP_Query();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$my_query->query('cat='. $id .'&posts_per_page=4&paged='.$paged);
while ($my_query->have_posts()) : $my_query->the_post();
?>
<?php get_the_content() ?>
<?php endwhile; ?>
<?php if ( $my_query->max_num_pages > 1 ) : ?>
<?php previous_posts_link( __( 'Previous', 'themename' ) ); ?>
<?php next_posts_link( __( 'Next', 'themename' ) ); ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "categories, pagination"
}
|
Query of custom post types only shows first post
I have a loop to show my custom post type of 'case_studies'. It originally showed all posts until I wanted to just show 3 specific posts. The problem is that it only shows the first post in my list of 'p=54,49,44'. What am I doing wrong?
$case_studies = new WP_Query();
$count = 0;
$case_studies->query('post_type=case_studies&p=54,49,44');
while($case_studies->have_posts()) : $case_studies->the_post(); $count++;
$custom = get_post_custom($post->ID);
$case_studies_image_url = $custom['second_image'][0];
|
I think you need to change:
$case_studies->query('post_type=case_studies&p=54,49,44');
to
$case_studies->query_posts( array( 'post__in' => array( 54, 49, 44 ) ) );
I'd look at this page for LOTS more examples. < when your there search for "Multiple Posts/Pages Handling".
Hope this helps, I'm still new to wordpress.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "custom post types, query"
}
|
Custom post type items open in archives?
I have my own custom post type under:
wordpress/custom
But when I open any item of this post type they open in:
wordpress/archives/custom/title
Why there's 'archives' and how to get rid of this from my urls?
The taxonomy is registered like below:
register_taxonomy("our_frontpage_types", array("frontpage"), array("hierarchical" => true, "label" => "Categories", "singular_label" => "Category", "rewrite" => true));
And the post is registered like:
add_action('init', 'fp_register');
* UPDATE *
Ok, now I know it was a problem with permalinks, BUT /%category%/%postname% is far from perfection. Is there something like %section%/%postname%?
|
WordPress will add archives base in the url if it thinks that the page an archive and when i had the problem it was because i named the custom post type and my custom taxonomy the same, is that the case?
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "custom post types, urls"
}
|
Bulk User Deletion
I've created a WordPress 3.0 site w/ MultiSite enabled and the BuddyPress plugin installed (latest available versions of each). Initially, the site did not have a captcha enabled and now there are hundreds of spam accounts created.
By default, the Super Admin panel for Users only shows 15 users at a time. I need to delete several hundred users and going through this page by page is monotonous.
Is there plugin available which would assist with bulk user deletion? I'd like to be able to select and delete a few hundred users at a time (or even better do a regex search by username).
Thanks.
|
Super Admin > Users. Screen Options (top right) > Show on screen __ users.
Be careful, listing hundreds of users could kill your server. Heh!
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "plugins, multisite, buddypress"
}
|
How to change what the post creation page looks like?
Is there a way (plugin, or something else) to set it where there is a drop down on the "New Post" page that allows you to choose a post type and the fields change allowing you to filter what content you are putting into a post without confusing a user by having 20 different custom fields on the "New Post" page.
Also, is there a plugin or other that can make custom fields with different value types (textarea, list, file upload, etc)?
|
This was asked over and over:
* Add custom field automatically to custom page types
* Redesigning Custom Post Type “Add New” page
and if you are not into coding the you can use plugins like
* Simple fields
* More Fields
* Verve Meta Boxes
hope this helps
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 2,
"tags": "posts, custom field"
}
|
Disable a plugin from ever upgrading?
Is there a way to mark a plugin as "never upgrade this plugin" ?
I can't upgrade my OpenID plugin, and this prevents me from clicking the otherwise convenient "Upgrade All Plugins" button.
|
Hi **@ripper234:**
Either 1.) edit the plugin header comment in the main plugin file and change the `Version:` value to something like 999, or 2.) move the plugin to the _"Must Use"_ plugin directory: `/wp-content/mu-plugins`.
Here's an example from `/wp-content/plugins/akismet/akismet.php` of the plugin header comment for Akismet:
/*
Plugin Name: Akismet
Plugin URI:
Description: Used by millions, Akismet is.....
Version: 2.5.2
Author: Automattic
Author URI:
License: GPLv2
*/
Here's a blog post that explains the _"Must Use"_ plugins _(albeit I don't understand why he chose the title he chose):_
* **Creating a custom functions plugin for end users**
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "plugins, upgrade"
}
|
Hold comments for moderation only if user is not logged in
Is there any way to allow logged-in users to post comments without them being held for moderation, while requiring that any comment from anonymous users be approved? I have developed a system for users who are members of our organization to log in automatically with their LDAP accounts, and would like for any of them to be able to comment without their comments being held for moderation. However, I want all anonymous third-party comments to be held for moderation. I don't see any way to do that with the current comment options - I can either hold all comments for moderation, hold all comments by users without 2 approved comments, or require users to log in to comment. How can I achieve this?
|
Here you go, paste this code in your themes `functions.php` file:
function loggedin_approved_comment($approved)
{
// No need to do the check if the comment is already approved anyway.
if (!$approved) {
if (is_user_logged_in()) {
// Note: 1/0, not true/false
$approved = 1;
}
}
return $approved;
}
// Action allows the comment automatic approval to be over-ridden.
add_action('pre_comment_approved', 'loggedin_approved_comment');
Make sure to enable Comment Moderation inside the Settings-panel of your WordPress install.
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 1,
"tags": "comments, users, moderation"
}
|
Problem with Simple Facebook Connect
I'm seeing this box in the "Edit Post" page, using the Simple Facebook Connect plugin 0.25 and WordPress 3.0.4:
> If you can see this, then there is some form of problem showing you the Facebook publishing buttons...
All other Facebook-related plugins are disabled. How can I debug this?
Posted an issue.
|
I added " in the Facebook URL (See the issue for more details).
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "facebook"
}
|
How to detect filter in URL in Category page?
I need to add an additional filter based on a category for posts that have a custom post_type.
For example, I have a page located at `/category/tasks` that lists all tasks. I need to make it so I can have additional pages that filter even further like `/category/tasks/current`, `category/tasks/future`, `/category/tasks/past`. I can figure out how to get the query to work, I just am not sure how to pick up the type of filter from the URL. (currently it goes to a page not found error when adding the additional word after /tasks)
|
If I'm understand the question right.... first login to the admin section. then click on "categories" its in the "Posts" accordion box. When your there you'll see all your categories. Next, following your example, you need to make "current", "future", and "past" all children of "tasks". this should achieve the desired URL. Let me know if I can help any more.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "custom post types, categories, urls, filters"
}
|
Are there any filters to add additional columns to the list table on edit-comments.php?
I'm trying to modify the display of the `edit-comments.php` admin page and I'm not seeing any filters in it comparable to `manage_posts_columns` etc.
Is there an easy way to do this? I'm thinking the only real way to go about doing this is to extend **WP_Comments_List_Table** with my own class, overwrite the `get_columns` and other related functions, and just add my own page to the admin menu which uses this new class in the same way that edit-comments.php uses **WP_Comments_List_Table**.
Is there an easier way to do this that I'm just not seeing?
|
I'm afraid that there is no easy way to get that done yet because the only hook i found is **manage_comments_custom_column** and that is an **action** hook and not a **filter** hook so you can't add columns like manage_posts_columns. so as far as i can tell the long way here is the only way. but you can almost duplicate the default edit-comments.php and extending small classes like wp_post_comments_list_table and more.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "admin, columns"
}
|
What are the recommended database permissions for WordPress?
I just got WP running on my own server. I am not trying to lock things down more. What permissions should the db user have to my WP db?
|
If you did want to lock things down.... a normal wordpress site will usually only require the database user to have SELECT, INSERT, UPDATE and DELETE.
If you want to use the automatic update feature it will also require CREATE and ALTER.
Some plugins may require other permissions but most won't.
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 12,
"tags": "mysql, security, permissions, privileges"
}
|
Looking for WordPress Slideshow Gallery Plugin
I'm looking to see if there is already a plugin that does a gallery slide show like Huffington Post does where it shows either one image or video then you click next to see the next one. There is no need for a rating system. I'm hoping there is so I don't have to figure out how to make one :)
<
Other examples:
<
<
**FOUND A SOLUTION USING NEXTGEN:** Actually someone found this post and they found the solution :) <
|
**FOUND A SOLUTION USING NEXTGEN:** Actually someone found this post and they found the solution :) <
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "gallery"
}
|
How to add another page in appearance tab of admin panel?
Currently I am working on Wordpress and I want to know can I add 1 more page in admin panel appearance menu so that it looks like this: ?
Appearance
Themes
Widgets
Menus
Editor
I want to add one more page after Editor like "Theme option".
|
You'd use the add_theme_page() function. Basically, it's the same as adding any other settings page, but instead of add_options_page(), you use add_theme_page().
More info:
* <
* <
* <
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 2,
"tags": "customization, admin menu"
}
|
How do I manually revert back to my old theme?
After changing themes I get
Fatal error: Call to undefined function add_editor_style() in /mydir/wp-content/themes/evolve/functions.php on line 8
I cannot even login to the administration panel
|
Simply Delete or rename the theme's directory.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "themes"
}
|
How to store a medium amount of options?
I develop a plugin that has a not too small number of settings. So far, there has been a fixed number of them, so I store them in a Wordpress option. Now I consider letting users define (an arbitrary number of) styles, that is sets of options. Since these will still be rather general options, none of the categories listed in the Codex really fits.
Storing all that stuff in one option is clearly not a good idea, but creating a whole database tables does not feel right, either. What are your recommendations?
Note that I post one idea I have as an answer in order to separate it from the question. Would mark the question CW, but that seems to be disabled here?
|
The hierarchy of storing data roughly goes like this (from less functional/complex to more):
1. Transients API
2. Options API
3. Settings API
4. Database Tables
5. Custom file cache
Since from your description Options are too limited and database too complex, I would look at Settings.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "plugin development, options"
}
|
How to change permalinks to show categoryname/post-name?
I've placed the string below into my custom permalinks input but it does not appear to have any effect...
> /%category%/%postname%/
I'm trying to insure that my post links are in the form of /category-name/post-name
|
Without a link to the site in question, it's hard to understand the exact problem. However, if the issue is the actual word "category" is being includes (i.e. example.com/category/category-name/post-name) then I would use this plugin (it's one I use on almost every site)
<
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "permalinks"
}
|
Return count for characters in the comment and perform action based on the length
I am calling recent comments into my template with
$comment->post_title
the variable length is specified like this :
SUBSTRING(comment_content,1,180)
how could I write a conditional statement just for comments that exceed the limits of the vairable >180 ?
I was thinking It would be good to have a ... for longer comments and a more link.
|
By using a function to perform that:
recent_comment_text_more($comment_content)
that function would look like (in case you're using PHP, part of your code looks from another language):
function recent_comment_text_more($comment_content, $more_href) {
if (strlen($comment_content) > 180) {
$comment_content = substr($comment_content, 0, 177) . sprintf('<a href="%s">... (more)</a>', $more_href);
}
return $comment_content;
}
Good luck!
# Multibyte charset safe variant
As pointed out in a comment, e.g. for UTF-8, see mb_internal_encoding() for specifying the encoding to use:
function recent_comment_text_more($comment_content, $more_href) {
if (mb_strlen($comment_content) > 180) {
$comment_content = mb_substr($comment_content, 0, 177) . sprintf('<a href="%s">... (more)</a>', $more_href);
}
return $comment_content;
}
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "comments, conditional content, php"
}
|
Undefined index error on options array element?
WP_DEBUG is telling me:
> Notice: Undefined index: no_cat_base in myplugin.php on line 20
Here's the lines of code where I'm pulling the value of "no_cat_base" from my options array called "myoptions"...
$myoptions = get_option('my_settings');
if($myoptions['no_cat_base']){//This is line 20}
Is the correct fix for this...
if ( isset($myoptions['no_cat_base'])){//do something}
|
just to be on the safe side use:
if (array_key_exists('no_cat_base', $myoptions) && isset($myoptions['no_cat_base'])){
//do your thing
}
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "errors, wp debug"
}
|
When would you use $_post instead of $post?
I've seen some examples that use $_post instead of $post. What's the difference and when would you use $_post instead of $post?
Example:
if (have_posts()) :
while (have_posts()) : the_post();
if(!in_category("some-category", $_post )) { do_something(); }
|
I'm not certain, but if you're talking about $_post as seen here:
<
It's referring to a post ID so they've probably added the underscore to avoid confusion. The $post variable is a post object with all the details of the post.
However, $_POST is a global PHP variable containing all the values sent from a form:
<
|
stackexchange-wordpress
|
{
"answer_score": 9,
"question_score": 1,
"tags": "php, variables, loop"
}
|
How do I add the same contact form to multiple wordpress sites and capture the response in one place or database?
I own a network of 100+ Wordpress based websites. All website are separate installations of Wordpress and are on different servers. I would like to
1. create one contact form
2. have it shown in the sidebar all of my Wordpress websites and
3. capture the responses in one database (instead of getting 100's of emails).
Ideally the form would be created and hosted in one place and then embedded into the other blogs (via iframe or other method?). That way I'd only have to make changes to the form in one place and have them apply to all sites.
I know there are countless plugins for creating contact forms, but none that would seem to address this situation. Any help would be greatly appreciated. Further, I'm not opposed to hiring someone to help with this situation if it's beyond the scope of this websites.
All the best, JB
|
the easiest way i can think of is to use a plugin that creates a form by shortcode like contact form 7 for example and I'll break it in to easy steps.
* Create the form on your main site or what ever site you would like to manage the forms data through.
* Create a page template with no header or footer just a plain loop and call `the_content`.
* Create a new page , add the Form's shortcode to it and set the template as your new page template.
* Get the URL of that page and create an iframe to it.
* On each site you would like to show the form just add the Iframe code to a sidebar text widget.
and that should do it.
Oh wait, you will probably need to add Contact form 7's Javascripts and css and i just read your question again and you are looking to save this forms in to database and since this plugin does'nt save to database on its own you can use an extenstion plugin called Contact Form 7 to Database or use a different forms plugin all together.
Hope this helps
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "plugins, sidebar, forms, contact"
}
|
wordpress site | All-in-one-cufon IE Issue
I have a site where i'm using the All-In-One Cufon (Wordpress Plugin), but having some issues getting it to render properly in IE.
The website: [removed]
The Problem: It works fine so far in Firefox and other browsers like Chrome. Even in internet explorer the first time the site loads it works fine but when I refresh the page or visit any other pages by clicking a link on the site it stops working (The text is still visible but cufon rendering doesn't work) :o
I have been trying to fix this since the past day without any success. I'm not 100% sure but I think it used to work fine awhile back but I just recently noticed this odd behavior and have no clue what could be making this happen.
My first thought was a conflict of a plugin, but I tried disabling ALL the plugins except the cufon and it still does the same thing.
Is anyone aware / experienced similar issue with their websites? and knows the solution?
|
The issue seems to have been resolved in the latest Release Candidate of IE9.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 1,
"tags": "plugins, php, jquery, javascript"
}
|
security concerns if using html data-* attribute for l10n?
I need to pass a localized multidimensional javascript object to a page. The object is constructed using php and represents some wp-theme settings. I cant find a way to utilize wp_localize_script for this, as it will not parse multidimensional arrays.
Instead I've come up with the solution to use a html5 data-* attribute for this and then using jQuery to retrieve it, hoping for this method to provide x-browser compatibility.
So on the page where I need to access the localized data I let php output:
<div id="localized" style="display:none" data-localized='{"user": "Doe", "skills": {"html":5, "css":4, "php":3} }'>
I then get that localized data using:
var my_localazed_data = $('#localized').data('localized');
It works fine. But my concern here is:
1) Is this browser compatible?
2) Are there any security concern to be aware of as compared to using wp_localize_script?
|
> Q: 1.) Is this browser compatible?
Yes, for all browsers supporting jQuery data(). jQuery is generally supported by most modern browsers.
> Q: 2) Are there any security concern to be aware of as compared to using wp_localize_script?
`wp_localize_script()` is mainly doing the same but it's keeping the data on the serverside and not within the DOM.
As always, making use of javascript and interacting with the DOM has security implications. You need to follow the rules to properly en- and de-code any arbitrary data safely so that injections can not introduce unintended behaviour.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, theme development, javascript, security"
}
|
How do I manage my users post before publish?
In my website , I allow to the new user to write posts.
but the problem is when the user write post. the state of post is publish. it is appear in front page.
I want to read it before the publish , I mean I want to approve it if it is useful or refuse it if it unuseful.
I wish you understand me.
Thank you very much ,
|
What role are you assigning to those users? According to Roles and Capabilities documentation in Codex it should be `Contributor` for users that are allowed to write posts, but not publish them.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 0,
"tags": "posts, users, publish"
}
|
How to set a page as homepage in stead of the newspages?
I need some help. I want the same as on this site: < (this is my website)
When you go to the home url you come to a page in stead of the newspage.
The newspages are in the submap /ipad
**So i have two questions:**
1: how do i get the newspages in the submap /ipad
2: How do i set my first created page permalink as homepage? Same as on this image:
> !enter image description here
where you see nothing after ` )
|
please make yourself comfortable with the settings WordPress has to offer regarding your Homepage or Startpage as some call it.
Those are _not_ configured via that _permalink setting_ of a specific page (as your image shows) but with options on the Settings Reading SubPanel (Wordpress Codex).
Probably Creating a Static Front Page (Wordpress Codex) is exactly what you're looking for.
This might not answer all your questions but might be helpful for a start.
|
stackexchange-wordpress
|
{
"answer_score": 5,
"question_score": 0,
"tags": "theme development, themes, permalinks"
}
|
Subscribe to email
I am looking for a way where, the users of my website will subscribe to a post, and when my post will be edited or updated they will be emailed by my posts contents,
My post contains, article, Twitter Updates, a Video How will the users get notification when my posts get updated and also when someone comments on posts
|
Try this two plugins:
1. Post Notification
2. Subscribe2
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "plugin recommendation, email, updates, subscription"
}
|
Disable author profile in post
I am managing a WP 3.0.4 site where every post has the profile of the author appended. Where is the setting to disable this?
|
There's no exact "setting" in the backend/Admin UI. You'll have to edit your template files (the php files that are in your theme folder). Search for something like `<a href=""></a>` where you got one (or more) of the php (wp native) function or variable:
* `the_author_posts_link();`
* `$curauth->user_url;`
* `get_the_author();`
* `get_author_posts_url();`
* ... or something theme specific
Helpful is always a link to the download of your theme or some template code.
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 1,
"tags": "posts"
}
|
How do I determine if a category exists by ID?
I know I can get a categories ID by calling get_cat_ID('category-slug'), however, what is the method to call to determine if a category exists by ID when you don't know the slug?
In other words, I need to determine if category id 1 exists. What's the function for this?
Can I just use if(get_category(1)) {//do something?}
|
There is `category_exists()` function, but it seems to be for internal use in admin so you can try `term_exists()` instead.
|
stackexchange-wordpress
|
{
"answer_score": 6,
"question_score": 2,
"tags": "plugin development"
}
|
Use WP 3.1 Internal Linking 'widget' as a meta_box
There is lots of information out there on how to customize meta boxes added with add_meta_box(), such as enabling WYSIWYG editors on textareas and uploading images.
What I have yet to find is a way to reuse WordPress 3.1 Internal Linking feature. Many of my custom fields contain urls to other pages on the site. The new Internal Linking feature would make it a lot easier for my users to find a page URL rather than having to remember it of cut & paste it.
Is the new Internal Linking feature reusable in conjunction with add_meta_box()?
|
WordPress 3.1 Internal Linking feature was coded as a TinyMCE editor plugin so its not really a widget or a meta box but you can code your own meta box and reuse the functiona needed for that.
The files you need to look at are
* /wp-includes/js/tinymce/wp-mce-link.php
* /wp-includes/js/tinymce/plugins/wplink/js/wplink.js and maybe a few more but these are the main files you will need to achieve this functionality.
Side note: I can tell you that up until now when ever i needed to let my user add a url to a post or a page as a custom field i always created a dropdown select with the names of my posts and there id as value, then when i needed to show that link i'd call `get_the_permalink(selected_ID);`. Now i know that this won't work in all cases but its an option and i wanted to post it here for future reference.
Hope this helps,
Ohad.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "custom field, linking"
}
|
Need help with rewrite_rules_array
I have a page that I access at /category/tasks and the file is located at wp-content/themes/my-theme/tasks.php. I would like to make it so I can add a flag after tasks and pick up the query strong in tasks.php. This works fine when I access the page with /category/tasks/?when=upcoming.
Can someone tell me how to use rewrite_rules_array so it will send the variable through the query string using the URL structure /category/tasks/upcoming?
|
Try this:
function when_rewrite_rules( $wp_rewrite ) {
$new_rules = array();
$new_rules['category/tasks/(\d*)$'] = 'index.php?when=$matches[1]';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_filter('generate_rewrite_rules','when_rewrite_rules');
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 3,
"tags": "url rewriting, rewrite rules"
}
|
jQuery UI & Admin (Calendar)
Am I smoking crack or why wouldn't this work? :/ This all seems pretty straightforward:
function admin_head()
{
?>
<link type="text/css" rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/jquery-ui-1.8.9.custom.css" />
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/theme-admin.js"></script>
<?php
}
add_action('admin_head', "admin_head");
And then in theme-admin.js ...
jQuery(document).ready(function($)
{
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true, dateFormat: 'dd/mm/yy', showOn: 'button', buttonImage: plugin_path + '/images/icon-datepicker.png', buttonImageOnly: true});
});
Thank you for any insight you can provide :) Cheers
|
Duh, if you're **image path is bust** and it's the only way it activates, it just won't load.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "custom post types, wp admin, jquery"
}
|
Anyway to specify what should appear in <title> in .php file?
Is there anyway I can set what text should appear in the tags before get_header() is called in my .php files that are inside my theme's directory?
|
It depends on your theme how exactly `<title>` is generated. At least some of it should be generated by `wp_title()` function, output of which you can filter at `wp_title` hook.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "title"
}
|
Override the default number of posts to show for a single loop?
Is is possible to override the set # of blog posts to show per page (as defined under Reading Settings in the WordPress admin)? I want to make it so a custom loop that I am using will show an unlimited number.
|
The argument that controls how many posts are shown in the query is posts_per_page
<?php query_posts( array(
'post_type' => 'post',
'posts_per_page' => -1 )
);
?>
Also to note is that there is a bug in the 3.0 branch which prevents the -1 integer from displaying all posts. It is fixed in 3.1 but a workaround would be to use a very high number instead of -1
see:
<
|
stackexchange-wordpress
|
{
"answer_score": 9,
"question_score": 4,
"tags": "posts, loop"
}
|
Create/Edit posts and auto-redirect back to listing page
Is there any way to possibly force a redirection to the post (type's) listing page (`edit.php?post_type=<post-type>`)?
~~**EDIT:** Since I got a LMGTFY link, let me clarify before I downvote it.~~
**Is there anyway to redirect the user forcibly to the post type's listing page AFTER they've already submitted the form to either edit the post or create a new post?**
|
* global `$post` or `$post_type` to check for your CPT;
* Post Status Transitions hooks to redirect on specific changes to the post;
* `wp_redirect()`.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "custom post types, redirect"
}
|
Sortable admin columns, when data isn't coming from post_meta
I have a custom post type that uses a custom taxonomy. I'm imposing a limit of a single term to each post (using a custom meta box drop down on the edit post screen for the CPT). The term for the taxonomy is assigned using the standard wp_set_object_terms() function. How can I make the taxonomy column sortable (using WP 3.1rc3)?
This post by Scribu got me almost there.
However, since I'm not using a numeric value stored in a meta key, the {name}_column_orderby function will not work for me.
How can I create sortable columns within the manage-edit screens, when the information that I'm listing does not come from the post_meta table?
|
See the follow-up post: <
|
stackexchange-wordpress
|
{
"answer_score": 9,
"question_score": 5,
"tags": "wp admin, taxonomy, sort, columns"
}
|
Why Do I get "wp_remote-get: could not handle for fopen()"?
I'm trying to get an image from Google but...
wp_remote_get returns me:
Could not open handle for fopen() to
v=1.0&q=whatever.whatever&key=MYKEYWHICHIDONTPOST&userip=127.0.0"
I don't know why:
* when I enter the url directly I do get results.
* all other wp_remote_gets in the same class work ok so yes php.ini allow=ok
this is the code i run:
$referer_url = get_bloginfo('url');
$referer = $parsed_url[host];
$google_images_url = self::GOOGLE_IMAGES_URL . "&q=" . $url_to_look_for . "&key=" . $key . "&userip=" . $_SERVER['REMOTE_ADDR'];
$response = wp_remote_get($google_images_url, array( 'headers' => array( 'Referer' => $referer)));
hmmm
|
Yep, I experienced that under some network configurations `https` links fail (my case was behind proxy server).
You can use Core Control plugin to test available HTTP transports and disable glitchy one. In my case bumping transport to curl solved issue.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "plugins, css"
}
|
How to show custom message once on plugin activation?
I know by watching the akismet plugin source how to show a custom message on the plugins page, but I want my message to appear only once after my plugin is activated.
How could i do this?
|
The easiest way would be to check for an stub get_option something like
$run_once = get_option('run_once');
if (!$run_once){
//show your custom message here
// then update the option so this message won't show again
update_option('run_once',true);
}
hope this helps
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 3,
"tags": "plugins, customization, plugin development"
}
|
changing body background color for custom post type in admin backend
i have a custom post type called 'auctions', and i'd like to be able to visually differentiate auctions from posts and pages **in the backend** by assigning a different background color to the auction post type.
this could be easily achieved if i had a way to assign a body class to admin pages pertaining to this specific post type, except i'm not sure as to how i'd go about that :).
any help would be greatly appreciated. thanks!
|
Easy and your css to overwrite the default style like this
add_action('admin_print_styles', 'auctions_admin_print_styles_332');
function auctions_admin_print_styles_332(){
if ((isset($_GET['post_type']) && $_GET['post_type'] == 'auctions') || (isset($post_type) && $post_type == 'auctions')){
//include your css file using wp_enqueue_style() somthing like
wp_enqueue_style( 'handle name', plugins_url('/style.css', __FILE__), array(), '1.0' );
// or a more hackish way would be to echo out the css style tag
}
}
so the class you are looking for is actualy an id "wpwrap" so you can use something like this:
<style type="text/css">
#wpwrap{background-color: #FFF;}
</style>
Hope this helps
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "admin"
}
|
How To Remove The "Click here to cancel reply" Link From The Wordpress Comment Form
I am trying to remove the "Click here to cancel reply" link from the Wordpress comment form on my posts. In the document there is an argument you can supply to the comment form function to remove the link, but it doesn't appear to be working. The documentation link: <
I have tried different values for the cancel_reply_link value including double quotes, double quotes with a space between them, a zero and a value of false; all of which were to no avail. Surely I am overlooking something here as removing that link is pretty common in Wordpress installations.
Here is the current function call with parameters that I am using at present:
<?php comment_form(
array(
'comment_notes_before' => FALSE,
'comment_notes_after' => FALSE,
'cancel_reply_link' => FALSE
)
); ?>
Your help is gratefully appreciated.
|
add_filter( 'cancel_comment_reply_link', '__return_false' );
See `/wp-includes/comment-template.php#function get_cancel_comment_reply_link()` for more background.
But if you do that the reply form will not move to the comment. The more interesting question is: Why doesn’t the link work for you? Do you have this line in your footer?
is_singular() and get_option( 'thread_comments' ) and wp_print_scripts( 'comment-reply' );
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 0,
"tags": "comments, comment form, themes, templates"
}
|
Replacing Scripts in Admin Load_Scripts
I'm currently creating a plugin that requires me to overwrite one of the Wordpress admin panel javascript files. I have recreated the file with the changes, I need to know how to replace the existing file that gets loaded in load_scripts.php (the script needs to be added in the same order).
I was hoping something like this would do the job:
wp_register_script('admin-widgets', WP_PLUGIN_URL. '/oak-automated-sidebars/oak-widgets.js'); wp_enqueue_script('admin-widgets');
But it doesn't seem to work, the original script is still loaded. Any suggestions?
|
You need to first deregister the script using wp_deregister_script
wp_deregister_script( 'admin-widgets' );
then use your code to re-register the script using your own js file:
wp_register_script('admin-widgets', WP_PLUGIN_URL. '/oak-automated-sidebars/oak-widgets.js');
wp_enqueue_script('admin-widgets');
Hope this Helps
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "plugin development, wp admin, wp enqueue script"
}
|
Wordpress homepage hangs in IE browsers
Anyone has any insight why < loads fine in FF, Chrome but hangs in IE for 20 seconds or more?
I have been hunting down the problem but reach an end.
|
Here's a waterfall chart showing your page load.
Your page loads in 3.1 seconds, but doesn't fire the document.ready event for another 27 seconds.
Aside from various room for optimization (you might split your .pngs across domains to make them load faster, for example) what this waterfall chart shows that it's not the page that is hung but the page content.
It is not WordPress or WordPress content, rather the page your WordPress content is on or some 3rd party plugin (for example) failing to put scripts in the footer. This is probably in part because of the heavy usage of images without image sprites, but likely there is also some JavaScript blocking the onload event.
I'd start with the JavaScript, debugging using a tool like Firebug.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "customization"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.