INSTRUCTION
stringlengths 11
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
How do I assign a custom post to all terms in a custom taxonomy?
I'm building a database of cities as a part of a "location" taxonomy. In order for the terms to render, as far as I've found, they need to have some type of content associated with them. My work-around is to create a "placeholder" post, assign it to the respective terms, then move it to the trash.
So, first, if you have any suggestions for a _better_ way to get the terms to display _without_ yet having content associated with them, please let me know!
Otherwise, what's the best way to bulk assign terms to a custom post? | With functions like get_terms, there is an argument hide_empty that will allow terms without associated posts to be shown. Set hide_empty to 0 and you will see your terms. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "terms, bulk"
} |
wp_set_object_terms timing out?
I have a list of 350 or so terms that I am trying to set to a post. Here's my code:
add_action('init', 'add_cities_to_story');
function add_cities_to_story() {
$cities_list = get_term_children('115', 'location'); // MA
wp_set_object_terms('632', $cities_list, 'location');
}
The trouble is that it appears to timeout about 3/4 of the way through the list.
Also, any ideas how to bulk _remove_ the tags from a post? :) | Dealing with terms is known to be very heavy operation.
The common tweak recommended is to use `wp_defer_term_counting()` to temporarily disable updating of terms count (which is stored persistently in database and so must be updated when you change terms). | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "bulk, terms"
} |
Suspicious URLs being loaded after hack and restore
I had a site that was hacked (had Arab words on the index.php), and all files deleted, but database still there.
I used Fantastico to install a clean release of WP 3.1, and I still some something suspicious. In lower right side of Firefox it says "Read www.clickcoupon.me". With FireBug and PageSpeed, I can see it's opening: < and < which both look extremely suspicious. These are not part of the standard WordPress are they?
The site is < As of the time I'm posting this, it is a default install from Fantastico. Unless they hacked my hosting company as well, I don't see how these files could be involved. | Found it! It was happening in FireFox but not Chrome. I looked at all my FireFox Extensions, and found "Browser Enhancements 1.0" and "Browser Coupons 1.0" <
The other URL was searchdock.me, and was reported as a "threat" here: <
I'm not sure when I installed these or why, but I don't think they were related to the hacking incident. It was just that when i was analyzing the hack incident carefully, I discovered these "extras" that probably didn't need to be on my machine anyway. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "hacked"
} |
add_action for admin_init hook with a parameter
In my theme, i want to create a generic way of inserting a meta box to a post, page, portfolio or other custom item.
For now, this action is like :
add_action('admin_init', 'add_portfolio_settings');
Which works fine, but has a problem. It currently works only for creating an add_meta_box for a portfolio item. However, what if i wanted to add the same to a post or page ?
So, i would like to have add_action passing an argument to my add_portfolio_settings function, ideally an array, that specifies what the types that a new meta box should register under.
I've read stuff and tried different things about do_action, but i cannot get it to work. Any ideas ? | What you want is quite possible, but not exactly mainstream technique. Take a look at my Implementing advanced add_* function wrappers question.
However your real issue here is not being unable to pass arguments. It is lack of context.
1. The simplest way to track context is inside your hooked function (check what page you are at, do something accordingly).
2. Slightly more complex is adding your own dynamic hook (Post Status Transirions are great example).
3. Even more complex is contextual hook. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "theme development"
} |
How to show my sidebar in specific page only?
I would like to show a plugin in a specific page's sidebar only.
**For Example:** I have the pages like ..
* home
* about us
* * sub page 1
* * sub page 2
* * sub page 3
* * sub page 4
**UPdate:**
i want to show, **plugin 1** in **sub page 1** and **sub page 4 only** and not to all other pages.i tried `is_page('sub page 1','sub page 4')` but not working :(.please help me. | The way to use is_page with multiple pages is as follows:
is_page(array(42,'about-me','Contact'));
You have to use the `array` keyword | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "plugins, sidebar, conditional content"
} |
Add class to current post in query_post
I have a query like this;
<?php $temp_query = $wp_query; ?>
<?php foreach(get_the_category() as $category) {
$cat = $category->cat_ID; }
query_posts('orderby=date&cat=' . $cat . '&order=desc&posts_per_page=-1');
?>
It grabs all the posts from the current category.
What i then do with this information is create a list of all the thumbnails associated with those posts.
What i would like to do is highlight in some way, the current post. (through a class or something), something that is obviously done automatically normally.
Thanks Alex | save the main current post id into a variable and compare it in the loop with the current post id; example:
<?php $this_post = $post->ID; ?>
<?php $temp_query = $wp_query; ?>
<?php foreach(get_the_category() as $category) {
$cat = $category->cat_ID;
}
query_posts('orderby=date&cat=' . $cat . '&order=desc&posts_per_page=-1');
while( have_posts() ) : ?>
<span<?php if( $this_post == $post->ID ) { echo ' class="current"'; } ?>>
/*output of your posts here*/
</span>
<?php endwhile;
?> | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "categories, query posts"
} |
Custom post type admin search
Is it possible to search in custom post type meta fields? I have posts, with many custom meta fields. Wordpress by default search only in title and in content. How can I change it?
**If you didn't understand what I am saying, please take a look at myscreenshot.** | Take a look at my answer to **how to filter post listing (in WP dashboard posts listing) using a custom field (search functionality) ?**
Its just what you are looking for. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 5,
"tags": "custom post types, admin, search"
} |
Using a _GET gives me a debug error (over my head)
Just looking for some advice on something that is bugging me. Please bear in mind I am a PHP noob :-)
I am passing a variable in the url to my WP index page like so:
<a href="<?php bloginfo('url');?>/?do=thing">Thing</a>
I am the catching that variable, and using it to show content like so:
<?php $do_that = $_GET["do"]; if($do_that == 'thing') : ?> etc
Naturally I am getting debug errors when the variable is not passed :-)
"Undefined index: do"
My question is what am I missing wrong? Obvious I spose?
Also is this bad practice? | The error is occurring as the $_GET array doesn't have the item $_GET['do'] in it. Therefore it throws this notice. To check if something exisits in the array try:
if( isset( $_GET['do'] ) )
$do_that = $_GET['do'];
else
$do_that = '';
or a cleaner method would be to use short hand notation
$do_that = ( isset( $_GET['do'] ) ) ? $_GET['do'] : ''; | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 2,
"tags": "themes, urls, debug"
} |
how can i get posts from custom post type particular taxonomy category
I have registered custom post type Article in my template using **register_post_type** function. and i also having taxonomy category for this article posts.
Here i want to filter the posts under particular category. using query post
How can i do this
Thanks in advance ! | If you read < in detail it outlines everything you need. Take a look at the following code sample taken from the codex. It should help you :)
$args = array(
'post_type' => 'Article', /* This is where you should put your Post Type */
'tax_query' => array(
array(
'taxonomy' => 'people',
'field' => 'slug',
'terms' => 'bob'
)
)
);
$query = new WP_Query( $args );
Please note that this query does NOT account for paginated data. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 1,
"tags": "custom post types, custom taxonomy, query posts"
} |
How to display a feature only if custom field value is set?
What i'm trying to do here is to modify the existing wp-postratings plugin. The function to display the ratings is:
<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
However, the above code displays the ratings on every post. What would be the conditional statement to add such that if a post has a custom field with name/value as ratings/yes
This way, based on the conditional statement, the ratings would be displayed only on posts where the custom field has the ratings/yes added. | <?php
// get the value of our custom field
$meta_value = get_post_meta($post->ID, 'ratings', true);
// if it's not empty and the_ratings function exists:
if( !empty($meta_value) && function_exists('the_ratings') ){
the_ratings();
} | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "conditional tags"
} |
Show Twitter followers count snippets don't work
No matter what I try I can't seem to get the code snippets to work that will display the number of followers of Twitter. I tried various ones as the Plugin I'm using is not showing the Twitter number at all, so I need to look for alternatives.
When I tried this snippet, for example, I got the following error message: <
Anybody any idea what's going wrong here? I think it's strange that the "Suscribers to text" plugin doesn't display the number of followres to begin with - otherwise I wouldn't have to look for alternatives. | Ouch, that snippet is ancient (I am kinda its author, more precisely adapted to twitter from other snippet). I would strongly consider using some newer solution.
I had later made newer and written from scratch version, try it < | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "twitter"
} |
Check if has pages?
So hard to find this info...
I'd like to know a way to find out if there are pages. Something like:
if (has_pages()) { /* do something */ }
I can't find a reference to any similar function... how might one go about finding out if there are pages. In case yr wondering I'd like to only show a pages menu if there are pages. | You could also use `wp_list_pages()` (Codex ref):
<?php
$has_pages = wp_list_pages( array( 'echo' => false ) );
if ( $has_pages ) {
// There are pages; do something
}
?> | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "pages, menus, conditional content"
} |
Event Management plugin
I am working on a site that has the option of using Event Expresso Event Manager Pro
The events part of the site is quite complicated, and needs to have \- a calendar \- a registration page \- 'buy tickets' functionality with both Paypal and < \- email confirmations
I haven't worked a lot with event plugins, can anyone recommend one of the above plugins over the other?
It sounds like there might be quite a lot of customization required, so I guess part of this question is, "Which is the easiest to customize?" | I know this does not meet your requirement of supporting Paypal and Authorize.net, but it does support Eventbrite, so it may be worth looking into:
The Events Calendar | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "events, calendar, plugin shopp"
} |
Wordpress FTP via admin panel slow
I am trying to delete some plugins via the Wordpress admin panel. Sometimes it deletes the plugin quite quickly, but other times it hangs.
I have access to my server, is there anything I can do to speed the performance up? | Is it a shared hosting?
Try rising the php memory limit. That will make wordpress admin go faster and your blog! | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "server, ftp"
} |
What level of permissions should the plugins folder be set to?
I am on a (non-hosted) server...what level of permissions should my plugins folder (and everything inside of it) be set to?
I seem to be having issues deleting or moving files inside of this folder... | Typically, the plugin folder only needs to be writable by your user account, but this could potentially vary depending on what user your web server is running as.
For example, most of my installs have the plugins folder set to 755, but this is because Apache is running as the same user as the owner of the folder. Check who your server is running as if you think the permissions are correct.
For more info on permissions and WordPress hardening in general, check out < | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "server"
} |
can i create 2 blog 'feeds' within one blog
Right now by blog has the 'home' section where all my new posts go, and 'pages' sections which are static pages that i can edit.
my question is, can i have another section that will behave like the 'home' link?
for example, can i have a page called 'cars' and a section called 'cats', where i can add new posts to either section?
if this is not possible, what are some workarounds?
**edit:** i dont want the blog homepage to contains ALL stories, i want it to contain all stories under the cat category, and the 'car' page contain all the posts under 'car' category.
in essence, it will be like i have 2 different blogs under a single blog | You can also create a custom feed and this to WP; use the function `add_feed()` for add a feed to WordPress and define the content inside the feed.
A example for feed with the drafts of WP can you read in this post. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 2,
"tags": "pages"
} |
Enclosures being deleted "automatically"
I am using PowerPress for my podcast support. I am working on some things on the web site and I swear, I set the enclosure, verify via phpMyAdmin that it is there. I don't touch anything on the site and check minutes later and the enclosure is missing. Huh?!?
Does anyone have any ideas where to start looking? I am running my own server on Ubuntu 11.x and using Apache for my web server. | Okay, looks like this is a "feature". | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "embed, customization, podcasting"
} |
Remove [ and ] from excerpt
I am displaying the wordpress posts on the index page with:
<?php the_excerpt(); ?>
In my functions.php file I have following code:
add_filter('excerpt_length', 'my_excerpt_length');
function my_excerpt_length($length) {
return 30; }
This works fine but it shows `[...]` at the end of excerpt. I want to remove these `[` and `]` and instead I want to show only three dots `...` . How can i do that? Thanks. | Use the `excerpt_more` filter hook:
function mytheme_excerpt_more( $text ) {
$text = '...';
return $text;
}
add_filter( 'excerpt_more', 'mytheme_excerpt_more' ); | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "excerpt"
} |
Any gallery plugins that allow commenting on single images?
I am looking for a gallery plugin that will allow users to comment on each individual photo as opposed to the entire gallery. I have tried Lazyest Gallery; however, it doesn't seem to be integrating well with another plugin I have installed called Facebook Comments for WordPress which I'm using to replace the default WordPress commenting system. Does such a plugin exist? Or perhaps there is a better solution? What do you guys think? | Usually your Wordpress theme will have an "attachments.php" page that would have a "single view" of the image in question. For an example: <
That gives you a "single" view of your image as well as comments. To test to see if your site has this, create a gallery and make sure to check "Attachment Page" when setting the Link Thumbnail to option.
!Gallery Image Options
Then view the post, click on the gallery image and it should take you to that images single page. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, gallery"
} |
Integrating Google Maps with custom marker and hover?
I want the exact output of this site. I want to edit the marker and hover options in the Google map, but I don't know how to do that. Please also list any ideas for Google Map plugins | Mappress allows for custom markers, but you need to pay for the pro version. <
Google Map Shortcode also supports custom markers in a shortcode <
Getting custom overlays on Google maps is actually pretty easy, you can read the docs here if you choose to work directly with the API, <
There are plenty of options here: < | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 3,
"tags": "plugins, plugin recommendation, google maps"
} |
Use child theme on certain pages and not others?
I have created a twenty-eleven child theme, I want to know if its possible to only load that child theme on certain pages, maybe with the custom page templates?
I have looked via google and on here and have found nothing on the twenty-eleven or very outdated posts.
Thanks | you can use page templates for that if you have a page template within your them, and if its a different theme all together then you can use **Page Theme** which is a plugin that can be used to display a different **theme** (not template) for each page/post of your blog. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "child theme"
} |
comments_popup_link without echo?
I would like to just get the HTML that comments_popup_link generates, and echo it later on. I don't see the comments_popup_link has an `$echo` parameter, and I don't see a get_comments_popup_link function, like there is get_the_ID, that _returns_ HTML istead of displaying it.
I'm using WordPress 3.1.2
What can I do? | I found this ticket that addresses my problem exactly: < | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 1,
"tags": "functions, comments"
} |
How to apply a patch?
I found a patch I want here:
<
I can see the _diff_ , but what do I do now? How can I get that code into my Wordpress? Do I have to copy it manually? Is there anywhere to download it from? | You can download the diff file from the bottom of the diff page.
The program to apply a diff is called "patch". It's widely available for various platforms.
Example usages: < | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 4,
"tags": "patch"
} |
WordPress folder ownership issues
Hi I set up wordpress on a VPS and I'm running into two problems:
1. Either WordPress asks for ftp details in order to update plugins or delete them
or
1. Through FTP I cannot delete files as I get a permission denied error.
Problem 1 is solved by running: sudo chown -R www-data public_html
Problem 2 is solved by running: sudo chown -R myusername public_html
Solving one problem creates the other apparently. I want to be able to login with my user to ftp and modify anything, while I also want wordpress to be able to update plugins and such things. Am I doing something wrong? | you can run something like
`sudo chown -R myusername:www-data public_html`
it will solve both the problems together | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 1,
"tags": "permissions"
} |
Getting thousands of spam comments
I am seeing that in the last 2 months blocked spam comments in Akismet have jumped from around 8k to more than 100k in each of the last two months. Is there any way to stop them being posted in the first place? | You can prevent some hits by blocking bots before akismet catches them, these plugins can be very effective.
**Plugins** :
* Bad Behavior plugin: <
* Honeypot Traps: <
* WP-Hashcash <
* Zig Trap <
Stop bots with no user agents from posting and directory browsing (this goes in your .htaccess)
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule .* - [F]
Options All -Indexes
Options +FollowSymLinks
If it's still a problem consider contacting your host and using a firewall to block persistant bots or IP ranges ( for instance here is a list of bad bots, < ). This is not super effective as is, but an example of what your logs can tell you ( most bad bots use common browser user-agents).
Check out services like Cloudflare. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "comments"
} |
Cron jobs for deactivated plugins
Hi I am using a plugin to view the cron jobs that are run by wordpress. I am noticing that there are jobs related to plugins I have deactivated and even deleted. Why is this so and how can I remove them? | This might be because the plugins you were using didnt deregister the crons it setup. To remove the crons use the following code in your functions file:
add_action("init", "clear_crons_left");
function clear_crons_left() {
wp_clear_scheduled_hook("cron_name");
}
Once thats run once you can safely remove it | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 3,
"tags": "cron"
} |
How to get 1 or 2 specific posts on top of my wordpress blog?
Does anyone know how to get 1 or 2 specific posts on top of my wordpress blog all the time? I mean just like in a forum where you can sticky a post so they are always on top of the other posts.
Is this maybe a simple line of code (i am not realy a coder) or does anyone knows a good plugin for this?
Any help would be realy appreciated. | Set it as a sticky post:
!enter image description here | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "plugins, posts, sticky post"
} |
echo get_post_meta of all post in a category to fill up a select field
I want to retrieve a specific post_meta of all posts contained in a specific category. I want to build a search form at the top of each category with a select field which would be filled up by the required post_meta of all the post contained in the category the user is currently in. Is this doable? Maybe it's possible with a loop which would look like:
`For each post_meta called "City" in all posts contained in category 'X', you must put it in <option value="City's name">City's name</option>`
So far, here is what I have been able to do.
<select>
<option value="" selected="selected">Please pick a city below...</option>
<option value="<?php echo get_post_meta($post->ID, 'City', true) ?>">
<?php echo get_post_meta($post->ID, 'City', true) ?>
</option>
</select>
Not much, I know. Any help, please ? Thank you in advance. | Thank you very much for your answers!
I finally found what I wanted here : < Here is the code :
<form name="search" action="" method="get">
<select name="City">
<?php
$metakey = 'city';
$cities = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC", $metakey) );
if ($cities) {
foreach ($cities as $city) {
echo "<option value=\"" . $city . "\">" . $city . "</option>";
}
}
?>
</select>
<input type="submit" value="search" />
</form>
This is a brilliant article and it helped me a lot! I hope it'll help others too. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "categories, custom field"
} |
Message box when accessed from iPad
I am still looking for a solution for this and can't seem to find it. I have the following code to start, but am not sure how to write the function to fire off a .js file. I need this to work on one specific page ID.
function ipad_alert() {
if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT'])) {?>
// link to .js file?
<?php }
}
add_action('init','ipad_alert'); | use `wp_enqueue_script()` to add a js file. I've hooked `wp_enqueue_scripts` so I can check `is_page()` for a specific page.
function ipad_alert() {
if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT']) && is_page(7) ) {
wp_enqueue_script('my_script', get_bloginfo('template_directory') . '/js/my_script.js');
}
}
add_action('wp_enqueue_scripts','ipad_alert'); | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "conditional content"
} |
Single-user registration to access all sites in WordPress MultiSite Network
Ok This is what i'm trying to achieve.
A site network where user can post their articles and get rewarded for each post.
For example, Lets say i have a main site example.com. I created a network like site1.example.com, site2.example.com, etc.
So lets say i have around 10 subsites in my network. Each subsite have one custom post type.
For example site1.example.com has custom post type videos and only dedicated for videos, site2.example.com has custom post type pictures and only dedicated for pictures, etc. Likewise i created 10 custom post types in 10 of my subsites.
Now i want user access in all network sites with one registration. I mean user who register in site2.example.com should able to access all my network sites and create new posts. They all should be able to access even if i add a new site in my network.
Is there any plugin available for this feature?. Please help me. Thanks | There sure is: Multi Site user Management
The plugin syncs your users across sites. I've used it extensively and it works really well. | stackexchange-wordpress | {
"answer_score": 5,
"question_score": 4,
"tags": "multisite, network admin"
} |
Import old SQL dump into new Wordpress version
I'm trying to restore a Wordpress blog from a backup. Unfortunately, all I have is an SQL dump of the database as generated by phpMyAdmin. The dump was created when the blog was running Wordpress 2.9/2.9.1/2.9.2. The new blog is a brand-new installation of Wordpress 3.2.1.
How can I import the contents of the SQL dump into the new Wordpress installation?
I tried importing the dump into the database using phpMyAdmin _before_ installing Wordpress, but then install.php tells me that Wordpress seems to be already installed and that I should delete the database tables. | If it is an older version of WP, you need to find out what version of WP generated the database, as WP upgrades the DB most times the files are upgraded and you should incrementally upgrade to also upgrade the database.
Look in the wp_options table for option 711 and see what the version is; option name will be site_transient_update_core and the value will be the download link, i.e. < which means the version is 3.2.1
Find the version and leave a comment below.
Depending on the age of the version, you need to do manual, incremental upgrades to get to at least 3.0 where you can use auto-update.
If you import/move a DB, no need to run install.php. Just upload all WP files and folders. See Moving WordPress « WordPress Codex | stackexchange-wordpress | {
"answer_score": 5,
"question_score": 3,
"tags": "import, upgrade, sql, backup"
} |
Need 'logo page' before wordpress page!
I made this website for my client using WordPress. It's all great but now he's asked me that when someone loads the website, before all the WP goodness, there's a page showing just the logo, then you click the logo and go to the main page.
I'm thinking I could either do this by changing WP's index to some other name and have the actual index file be the logo thing etc; or have a pop-up* on the actual WP index that darkens the rest of the page, then you click the logo and it's gone, allowing you to navigate the page normally. It would have to appear only the first time the user loads the page and not when you 'come back' to it from another page.
*Like when you click a screenshot here panic.com/coda for example.
Can anyone help me with either option or show me a new one?
Thanks! | Just tell him that doing so is bad for SEO and no one has done this since 1998. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "logo, customization"
} |
What Triggers a Plugin Update Alert
How does WordPress know a plugin has an available update?
Is the process handled by the readme.txt file? I am trying to manage 3rd party plugins that I alter in an effort to better fit/meet the needs of my instance of WordPress but I would like to maintain the functionality that alerts the CMS user that an update is available for the 3rd party plugin.
If I alter a plugin’s title will WordPress still know if there is an update to that plugin's code base? E.g. ‘Plugin Name’ (changed to) ‘Plugin Name – Modified’ | Basically it sends a list of your plugins to the wordpress.org API server, which does some black magic to try to figure out if any of the plugins you have match the ones it has, then it returns version info back for them.
The API uses a rather elaborate mechanism to match plugins against plugins it knows about, but these are the main things checked for: Plugin URI, Plugin Name, and Plugin slug (the directory name the plugin is in)
Change any of those and you reduce the chances of it finding a match, but it might still get it if two of them match, for example.
Info in the readme.txt is _not_ used for this. The header of the plugin's PHP file itself is used. | stackexchange-wordpress | {
"answer_score": 5,
"question_score": 2,
"tags": "plugins, updates"
} |
Quick login from mobile phone
I have a site which is essentially a blog carrying alerts to Doctors. The idea is that the Doctors will get an SMS alerting them to the fact that a new alert has been posted and a link to the alert. The alert will contain images. It is public, hidden from SE but might contain some sensitive info. I was wondering if there was any way of authenticating a user by mobile phone number, or any easy way for a mobile phone user to log in to a Wordpress site? | This is complex and considering the sensitive nature of the application and the usage "doctor alerts" I would really consider not using a blog platform.
There are a lot of systems out there that support secure sms with options for media.
If you must for some reason use WordPress, to authenticate users have a look at some of the HTTP authentication plugins, OAuth, XML-RPC, or just regular logins with cookie support and a mobile friendly theme.
ps. You cannot get a mobile number unless the user gives it to you. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "mobile"
} |
Disabling tooltip on menu items
For some reason, my menu items are showing tooltips on hover-over- In other words, the menu links have "title" attributes being added to them. Looking at my other, older WordPress sites, this is not the case. I can't remember having this issue before- Why would this be happening?
Thanks- | Here’s the code to remove it from wp_page_menu(), wp_nav_menu() and wp_list_categories() function:
function my_menu_notitle( $menu ){
return $menu = preg_replace('/ title=\"(.*?)\"/', '', $menu );
}
add_filter( 'wp_nav_menu', 'my_menu_notitle' );
add_filter( 'wp_page_menu', 'my_menu_notitle' );
add_filter( 'wp_list_categories', 'my_menu_notitle' );
Source | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "menus"
} |
Get only immediate children (and not grandchildren) of a hierarchical custom taxonomy term
Say, for example, I have the following custom taxonomy:
Term 1
Term 1.1
Term 1.2
Term 1.2.1
Term 1.2.2
Term 1.3
Term 2
Term 2.1
How can I get the children terms of Term 1, not including grandchildren? That is, I want my results to include only Term 1.1, Term 1.2, and Term 1.3. Thanks. | possibly with `get_terms()` and the `'parent'` parameter: < | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "custom taxonomy, taxonomy, terms, children"
} |
Display a paragraph in the index page that won't be displayed in the single post
Can i make it possible for an excerpt to be displayed in the index page but that part of the excerpt will not be displayed in the single post anymore? | Certainly: use the "Excerpt" textarea on the Post Edit screen. It should be immediately beneath the "Content" textarea; if not, check Screen Options (tab in the upper right-hand corner), and ensure that the "Excerpt" checkbox is enabled/checked. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "content, excerpt"
} |
Using password protection to load different page elements?
I have a page that is password protected, and I wish to removed some parts of the theme, and add others. Can I do that? Is there a check I can do in the theme files to see if a user has entered the password or not? | Just use the `post_password_required()` conditional:
<?php
if ( post_password_required() ) {
// Post is password-protected; do something
} else {
// Post is NOT password-protected; do something else
}
?> | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugin development, theme development, security, password"
} |
How to parse row results from $wpdb -> get_results
I have the following:
$query = 'SELECT * FROM wp_pod_tbl_add_questions WHERE id LIKE '. $id;
$row = $wpdb -> get_results($query);
How do I get the columns named 'id' and 'name' from $row? | foreach( $wpdb->get_results("SELECT * FROM your_table_name WHERE id LIKE' . $id . ';") as $key => $row) {
// each column in your row will be accessible like this
$my_column = $row->column_name;}
More info here | stackexchange-wordpress | {
"answer_score": 21,
"question_score": 13,
"tags": "wpdb"
} |
Can I setup WordPress in a subdirectory and then point my URL to the subdirectory when I'm ready to go live?
I have a client that has a current WordPress installation in their website root, and they are creating a new WordPress site which is in a subdirectory during development. My question is, what do I do when they are ready to go live and replace their current WordPress install with the new dev version? Can they just point their main URL to the subdirectory instead of having to move the entire dev site into the root of their website? Will this work with WordPress? | WordPress allows for this setup, and they have complete instructions here:
Giving WordPress its Own Directory While Leaving Your Blog in the Root Directory
I personally would move the files because to me it's cleaner, but the above mentioned solution should work for you. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 1,
"tags": "migration"
} |
How to noindex nofollow custom post type?
I've created a custom post type that displays the individual entries collectively on a page. However, I've found that Google is not only indexing the page, but the individual posts as well.
I only want the page to be indexed and followed, and not the posts. Is there any way to accomplish this? | Answering my own question here:
The WordPress SEO plugin provides a menu for all posts and pages, including custom post types, that includes noindex and nofollow options. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 1,
"tags": "custom post types, nofollow, noindex"
} |
How to list ALL Pages in the dashboard?
I'm wanting to find a way to have all pages listed without paging and to do so in a method that isn't going to be over-written when I update WordPress, i.e. in the form of a hook.
The page is in the administration:
!all pages
With all the pages being listed I can then use javascript to do collapsing to show/hide subpages, I'm not phased about load times of the page or anything, just cant have this method usable if paging is also used, all pages need to be listed on 1 page.
As I'm wanting to do this in the admin area, I'm not even sure if this is do-able without breaking when updating. | If that listing has too many pages, maybe you'll run into troubles.
You probably already know that this can be set in the `Screen Options` of the page `
If you try to put a really high value there, this warning pops up and the system doesn't accept it:
!1500 pages
But the following permanently sets this value to 2000.
I don't have more than 999 pages to test if that limit that WordPress is warning about will be overriden or not, but the 2k shows up after refreshing the page, and keeps there if you try to lower it.
add_filter( 'get_user_metadata', 'pages_per_page_wpse_23503', 10, 4 );
function pages_per_page_wpse_23503( $check, $object_id, $meta_key, $single )
{
if( 'edit_page_per_page' == $meta_key )
return 2000;
return $check;
} | stackexchange-wordpress | {
"answer_score": 9,
"question_score": 5,
"tags": "wp admin, pages"
} |
WordPress site causing lots of server IO
Hi I have a VPS and one particular site is apparently causing the server to crash and I am getting alerts about lots of IO going on. How can I troubleshoot to see what is causing the extra load? | 1) Try WordPress › WPDB Profiling « WordPress Plugins to see what is running all the queries.
2) Clearing post and page revisions will greatly reduce the size of a WP database - up to 90% in some cases - with a huge return in speed and lower server load. Run as SQL query in phpmyadmin to delete revisions; change table prefix as necessary:
DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'
Then optimize all tables. And then add
`define ('WP_POST_REVISIONS', FALSE);`
near the top of wp-config.php to disable future revisions.
3) Check your permalink structure: Category in Permalinks Considered Harmful » Otto on WordPress | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "server"
} |
Exclude category from drop down list form
I need a bit of quick help. How do I exclude category ID number 50 for example in drop down list form in Wordpress?
I have this code and I need to just insert the excluded category id.
<?php
$cate_id = retrieve_cat_data(true);
$cate_name = retrieve_cat_data(false);
for ($i = 0; $i < count($cate_name); $i++ ) {
?>
<option value="<?php echo $cate_id[$i]; ?>"><?php echo $cate_name[$i]; ?>
</option><?php } ?>
Thanks in advance to everyone :) | try:
<?php
$cat_to_EXCLUDE = 50;
$cate_id = retrieve_cat_data(true);
$cate_name = retrieve_cat_data(false);
for ($i = 0; $i < count($cate_name); $i++ ) {
?>
if ($cate_id[$i] != $cat_to_EXCLUDE){
<option value="<?php echo $cate_id[$i]; ?>"><?php echo $cate_name[$i]; ?>
</option><?php }} ?>
## update:
if you search your theme's functions.php file i bet you will find a function named `retrieve_cat_data`
anyway you can simple create a dropdown using `wp_dropdown_categories` and you can exclude a category with its `exclude` argument :
<?php wp_dropdown_categories('exclude=50'); ?> | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "categories, forms, dropdown, exclude"
} |
How can i get count from query post
How can i get the row counts in query post like mysql count(*).
$obj_name = new WP_Query($args);
while ($obj_name->have_posts()) : $obj_name->the_post();
// here i want to predict looping counts
endwhile;
How can i do this. | $num = $obj_name->post_count;
Reference: wp_query | stackexchange-wordpress | {
"answer_score": 22,
"question_score": 25,
"tags": "query posts, wp query"
} |
How to import my YouTube channel into WordPress?
I want to know how to import my YouTube channel into my WordPress website?
* * *
Example:
I have a YouTube channel with 7 videos. I want to bring all the videos into my WordPress website's sidebar. If I click the listed videos from my channel's list, it'll need to play. For more reference this is the sample output that I need:
!screenshot of desired video layout | I'd use the plugin Tubepress. It has a lot of options to suit your needs, such as a sidebar widget that can play your videos in a lightbox for example. I used it a few times, it's quite powerfull and customizable. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "plugins, customization, videos, youtube"
} |
Change the 'published on' text?
I am using the date and time in the post dialogue to log the date and time of future events, and would like to change the text to reflect that.
Is there an action hook I can tap into to achieve that?
Also, it would be perfect if I could pull those controls out of the 'publish dialogue', and add it to my own meta box.
!Publish dialogue | Use a `gettext` filter and match against the text.
add_filter( 'gettext', 'filter_published_on', 10000, 2 );
function filter_published_on( $trans, $text ) {
if( 'Published on: <b>%1$s</b>' == $text ) {
global $post;
switch( $post->post_type ) {
case 'your-posttype':
return 'Whatever on: <strong>%1$s</strong>';
break;
default:
return $trans;
break;
}
}
return $trans;
}
The alternative would be to copy the publish metabox code, and change the callback function for that metabox to your copied(and modified) version of the function, so you can do what you want with the callback code. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "plugin development, theme development, date time, hacks"
} |
Feedburner doesn't update when "scheduled post" publishes
I've searched around and can't find anything on this, so thought I'd see if y'all could help. I am successfully scheduling posts and having them publish - no "missed schedule" problems - but when a scheduled post is published, WordPress does not ping Feedburner, and my feed is not updated. I can manually go into Feedburner and update the feed, but that's a pain (well, it's easy, but I forget to do it! that's the whole point of scheduling posts! :-) ).
Does anyone know of a setting in either Feedburner or WordPress that I need to change to make this work? My 'privacy' settings are set to visible to search engines. Here's the site if that helps in any way: <
Thanks for your help! | That's weird, but you can try this. Go to **WordPress Dashboard > Settings > Writing** administration screen, and to the existing URIs listed under **Update Services** , add this:
**More Info:** WordPress Codex — XML-RPC Ping Services | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 2,
"tags": "feedburner, scheduled posts"
} |
placeholder text in category form label
Is there a way to put a placeholder text in the category form label? Right now the label is empty and has a dropdown menu filled with categories. I want to make a dummy placeholder text which will be something to : CHOOSE THE CATEGORY!
<option value="<option value="<?php wp_dropdown_categories('exclude=34, selected=0'); ?>
</option>
Thanks in advance! | You can add it as an argument:
<?php wp_dropdown_categories( 'show_option_none=CHOOSE THE CATEGORY!' ); ?>
Reference: wp_dropdown_categories | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "forms, text"
} |
Trouble with SQL SELECT inside switch_to_blog()
I'm using switch_to_blog() and restore_current_blog() to perform some functions across a multi site install. One of the things I'm trying to do is select a very specific post using get_row(). My function looks like this:
$prefix = $wpdb->prefix;
$tbl = $prefix;
$product = $wpdb->get_row("SELECT * FROM {$tbl}_posts WHERE ID = 4253");
print_r($product); exit;
The post with ID 4253 definitely exists, and I know for sure that the prefix is correct, however print_r returns absolutely nothing, nor does `echo $product->post_title;`
Any ideas? | **Edit:** You have an extra underscore in your table name, it becomes `wp__posts` in your case. Better use like how I have shown below :)
* * *
First, use table names like the following and try var_dump to see if it returns NULL. In case the Post ID doesn't exist, `$product` will be `NULL`, which only var_dump can show.
` $product = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = 4253"); var_dump( $product ); ` | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "multisite, switch to blog, get row"
} |
Menu in widget with yahoo style
I would like to know the procedure to put my categories in the left menu on the widget in the same style of yahoo
I like this style: ScreenShot-> <
what is the best option?
html and use a field to do manually? how would the css? | Check your site source to see what classes do your category links have on them, then style these classes with CSS, like:
.category-5 a{
background:transparent url(images/...) no-repeat left top;
padding-left: 25px;
} | stackexchange-wordpress | {
"answer_score": 1,
"question_score": -1,
"tags": "menus"
} |
How can I set a vote on the comments?
In this wordpress blog, one can vote the comments. I am wondering how can I set up this function in my wordpress blog?
!enter image description here | If your blog is self-hosted, the easiest way to add a comment voting system is to install a plugin (e.g. Comment Rating).
If your blog is on WordPress.com, then you'd need to go through the options the options on WordPress.com to see where you could enable that functionality. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "blog, support"
} |
Multiple Content Shortcodes
I was trying to create a shortcode for a multiple tabs panel. The user can set the number of tabs, the titles and the content for each. It would be something like :
[tabs number='4']
[tab title='First_tab_title']first tab content[/first_tab]
...
...
[/tabs]
Now, i am wondering. Although it can be done like this, i don't like that i have to create separate shortcodes, like tabs and tab. Is there another better way to pass all this information to a single [tabs] shortcode ? | You might be able to hack a conditional for 1 shortcode but it seems wonky. Typically you use 2 parameters just like you were using raw html.
There is a smart way around this using custom fields ( which I just happened to do recently).
It does not use any shortcodes at all, the logic is simple it has a custom fields called "tab 1, tab 2, tab 3 , etc" , if no data is entered no tab panels shows up, if there is data in the tab field the panels shows up and dynamically adds tabs per field that is filled out.
I just use jquery tools for the tab panel and default WordPress conditionals for the meta fields, `get_post_custom_values` specifically. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "theme development, shortcode"
} |
attach CPT data to a taxonomy
I'm trying to create a site where a 'Game' has a set of information (im thinking it will be a custom post type, with a 'link' field, 'developer' as a taxonomy, 'price', 'release date' and some other information.
I want to be able to make a post, in a category (such as 'reviews') which links to the relevant game and can pull some of this metadata into a template.
SO... the review is it's own post, it has it's own info, tags etc. BUT. is linked to the 'Game' so i can pull in the 'price', 'developer' information etc. AND when i go to the game page, i should be able to find the articles linked to it via the taxonomy.
Is there a way to do this? I have given it some substantial googling to no avail. Any ideas, thoughts or links would be greatly appreciated. | I would create a separate Reviews CPT. In the Reviews write screen, I would add a metabox with a select input contain each Game CPT as an option. Using the metabox, you can associate the Game ID as postmeta with the Review. Finally, in your template page that displays the review, you can easily retrieve the Game ID, which will allow you to display all of the relevant Game information on the Review page.
For an even easier solution than the metabox, you can simply add a custom field like "game_id" and manually add the game id. It's simpler than creating a metabox, but it's not as pretty :) | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "custom post types, custom taxonomy, customization, query posts"
} |
just show the field comment by clicking button
when we open a post, we at the bottom of the page field to post a comment
I would like to hide this field.
if there are comments, usually shows them
however to leave a comment, click a button
with this, the field appears to leave a comment
Anyone have a clue how to do this?
Through either normal or ajax | you can do this very easily with jQuery
simply wrap your comment form in a div and hide, add a button or a link and on his click event show the comment form so smoothing like this:
<a href="#" ID="Leave_a_comment">Leave a Comment</a>
<div id="comment_form_wrapper" style="display: none;">
<?php comments_template( '', true ); ?>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#Leave_a_comment').click(function() {
$('#comment_form_wrapper').show();
});
});
</script> | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "comments, buttons"
} |
Page comes up blank using w3 total cache
Im using the W3 Total Cache plugin on my site, and I made page using the wp_list_comments and for some reason the page keeps coming up blank, it comes back after I disable the plugin but when i enable it everything goes blank again does anyone have a suggestion on how iI can fix this, im new to this plugin.
thanks | You can turn off caching for your wp_list_comments template by placing `define('DONOTCACHEPAGE', true);` at the top of the page.
Other constants available on a per page or template basis are:
* `define('DONOTCACHEDB', true);`
Disables database caching for given page.
* `define('DONOTMINIFY', true);`
Disables minify for a given page.
* `define('DONOTCDN', true);`
Disables content delivery network for a given page.
* `define('DONOTCACHCEOBJECT', true);`
Disables object cache for a given page. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "comments, pages, plugin w3 total cache"
} |
Search post in all blogs in WPMU?
Is there a coding doc or tutorial to create a SEARCH where it search post in all Blogs in WPMU that will place in WPMU primary site SEARCH? | Take a look at **WPMU Global Search** plugin which can easily search through all blogs into your WordPress MU posts by post title, post content or post author.
and if you are not looking for a plugin then just take a look at the code and see how it's done. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "multisite"
} |
Facebook like plugin with Multi Option-Needed
i need to integrate facebook like button with some of additional features.
those are..
* every article/post has a 'Like' button (so that using this, when someone clicks 'Like' it'll appear in their Facebook news feed and add them to my Facebook page count direct from within my site)
please help me to get all these features with like button. is there any plugin done? or how to achieve from code? | You can't do the multi-like thing, but I use my plugin Simple Facebook Connect for this sort of thing. It has some features that might help you out.
1. The Like module lets you add the Like button to all the posts and such.
2. The Fan Box widget lets you add a fan box to your sidebar. That like button in the Fan Box (Like box) is actually for your Facebook Page. When somebody likes it, then they're liking your page on FB.
3. The Publish module lets your posts get published to your Facebook Page automatically, and users who have liked your page will thus see your new posts appear in their home streams.
I recommend using the beta version of the plugin, it tends to work better and is getting very near release: < | stackexchange-wordpress | {
"answer_score": 1,
"question_score": -1,
"tags": "plugins, plugin recommendation, facebook"
} |
Color java code the way it is colored in eclipse
There are a lot of plugins that color code. But most java developers work with Eclipse and Eclipse has a very specific way of coloring code.
Is there a plugin that colors code exactly the same way Eclipse does? | The majority of the Syntax Highlight plugins work in a way that they create divs,spans with classes styled by css and you can simply overwrite that style with your own css to match the eclipse colors.
## Update
turns out someone has done the job for you, take a look at SyntaxHighlighter Evolved which has an eclipse theme. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "plugins, syntax highlighting"
} |
How do I add an indicator to my .menu-item if it contains a .sub-menu?
If your common with the code that wp_nav_menu function generates. You should know what im asking for.
I need to add an indicator like a plus sign or an arrow to indicate that this menu-item has a sub-menu. I cant find a class or id that would allow me to do that.
Im guessing ill need a plugin for this? BUT I need some opinion first.
Thanks.. | I would do this with JS I'm afraid. It's the quickest simplest form. Using jQuery I have this snippet.
jQuery(function($){
$('.menu li:has(".sub-menu")').addClass('has-sub-menu');
});
Then you can use CSS to do what you need :) | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "css, navigation"
} |
What is the very earliest action hook you can call?
After the solution to this question was to get a function to launch BEFORE the `init` action is fired by taking the sequence out of its function, it got me thinking, is there any earlier in the WP load sequence that I can hook a function into? | `muplugins_loaded` is the earliest hook.
> Depending on your wordpress setup, you may not have any plugins in the `MU_PLUGINS` directory. In that case this hook may not fire.
The next best hook to trigger is `plugins_loaded`.
**RESOURCES**
1. WordPress Codex - Action Reference List
2. Q/A: How to get WordPress' hook run sequence?
3. Q/A: Make sense of WP Load Core | stackexchange-wordpress | {
"answer_score": 19,
"question_score": 22,
"tags": "filters, actions, wp load.php, init"
} |
How to add logo to rss feed
I came across this function to add image to rss feed. However, I keep getting lots of syntax errors.
/* Add RSS Logo */
function addRssImage() {
echo "<image>
<title>My Title</title>
<url>" . get_bloginfo('template_directory') . "/images/logo.png</url>
<link>" . get_bloginfo('url') ."</link>
<width>300</width>
<height>60</height>
<description>MyDomain.com</description>
</image>";
add_action('rss2_head', 'addRssImage');
/* End RSS Logo */ | The code you posted is missing an ending `}`
here is a fixed and tested version of that code, so if you still get errors they are coming from another place
function addRssImage() {
echo "<image>
<title>My Title</title>
<url>" . get_bloginfo('template_directory') . "/images/logo.png</url>
<link>" . get_bloginfo('url') ."</link>
<width>300</width>
<height>60</height>
<description>MyDomain.com</description>
</image>";
}
add_action('rss2_head', 'addRssImage'); | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "rss"
} |
Maximum protection without using password/login
I want to hide my WordPress site (or any website) from the world and only allow certain users to enter. What's the best way of doing this without setting up user accounts and passwords? Or perhaps more precise, what's the maximum protection I can get without using accounts?
Of course, I've chosen to block search engines under settings->privacy already. But I've thought about blocking people from linking directly to images and files, how can that be done? Is it by putting all the uploads (files/images) in a hidden folder somewhere outside of the WP structure? How do I do that?
Thanks! | How to restrict access to uploaded files?
There's an answer there to help you restrict access to images and other downloadable files. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "privacy"
} |
breadcrumb need to show all pages and subpages
am using Breadcrumb NavXT plugin.
i want to show all the pages and subpages in breadcrumb.i know this is tough to understand, so am explain briefly here.
* * *
i have the pages:
->mainpage
\--->subpage1
\--->subpage2
\--->subpage3
if i select **main page** it need to show **you are here>subpage1>subpage2>subpage3**
if i select **subpage3** it need to show **mainpage>subpage1>subpage2>you are here**
if i select **subpage1** it need to show **subpage2>subpage3>mainpage>you are here**
i guess,now you got my question.breadcrumb need to show circularly with all pages. please help me to achieve this. any plugin do this? or any code?:) | That's not traditionally how breadcrumb navigation works, as I'm guessing you've discovered if you're trying to implement Breadcrumb NavXT. :) You might have better luck styling wp_list_pages so the links display horizontally and highlight the page you're on? Here's where it describes how to display the current page / ancestors / children.
Best of luck! | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "plugins, plugin development, plugin recommendation, breadcrumb"
} |
Create pretty permalink for a post knowing the permalink structure
How can I generate a pretty permalink correctly for a post knowing the permalink structure?
My posts where processed with the FeedWordPress plugin with the "Link" setting set to "Permalinks point to: The copy on the original website".
So for all the posts in the admin area when editing a post the "Permalink" field under the post title shows an original, external site's URL, which is stored in the "syndication_permalink" meta data.
What I would like to do is to generate a pretty permalink for all such posts that would point to a local host (i.e. the post will have a permalink of type " rather than have an external link to a source), so that I can update the permalinks in DB.
I can get the permalink structure using `get_option('permalink_structure')`. Is there a WP function that I can use to get a pretty permalink generated correctly for a post by its ID?
Hope that makes sense.
Thanks, Dasha | GUID and permalink are two completely independent things. GUIDs are usually based on permalinks, but they don't have to be. Permalinks are not based on GUIDs in any way in modern WP (it had been changed long ago).
If you permalinks are not being generated correctly then that plugin (or some other) is breaking something in a bad way, it is unrelated to what your GUIDs contain. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 2,
"tags": "posts, permalinks, feed"
} |
How to redirect root blog to a specific one in multilang WP?
After installation I've got a default root blog '/'. Then I've created a new one '/en'. I really don't want to use the default blog. How can I redirect all accesses from / to /en ? | In your .htaccess file in the main '/' directory, put:
# This allows you to redirect index.html to a specific subfolder
Redirect /index.html | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "multisite, redirect"
} |
Scheduled event does not run at midnight
I have an event scheduled to fetch feeds from different sources at midnight. I believe for some reason it is not being triggered. I use Core Control plugin for testing. When I 'Run Now' through it, it works fine. What could be possible reason? Any hint that could facilitate me to get to the cause?
There is no argument to the handler and it is a reoccurring once daily task. | WP-Cron is not a guaranteed time task scheduler. The trigger for WP-Cron is somebody visiting the site itself, so if nobody visits the site at midnight, then the job doesn't run until somebody does visit the site later.
Similarly, if you use a whole page caching mechanism like WP-Super-Cache, then anonymous users will not really be "visiting" the site since they're getting cached pages. So that can impact WP-Cron's ability to run on time as well.
If you need to run timed events precisely, then you need to use a real cron mechanism instead. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 2,
"tags": "plugin development, cron, feed"
} |
Second menu not showing
I am running WP 3.2.1 on a dedicated server and having a little trouble with a second menu.
I have a menu at the top of the page which is working fine but I've added a secondary left menu to the left column which is currently showing the top menu despite it being selected in the admin to show the left menu.
In my functions.php I have:
register_nav_menu( 'left-menu', __( 'Left Menu', 'rsi' ) );
register_nav_menu( 'top-menu', __( 'Top Menu', 'rsi' ) );
Then in my theme files I've called them up using:
<?php wp_nav_menu( array('rsi' => 'left-menu' ));?>
<?php wp_nav_menu( array('rsi' => 'top-menu' ));?>
What am I missing? | You need to pass an array of menus to the `register_nav_menu` function like so:
register_nav_menus(
array(
'menu-1' => 'Menu Top',
'menu-2' => 'Menu Bottom'
)
);
You then call them in your theme:
<?php wp_nav_menu( array( 'theme_location' => 'menu-2' ) ); ?> | stackexchange-wordpress | {
"answer_score": 5,
"question_score": 1,
"tags": "theme development, menus"
} |
Some users getting a 404 when previewing draft posts/pages
I have a WP network and have found that users with roles other than "super user" (admins, editors, authors, etc.) are getting a 404 when trying to preview draft posts/pages/custom post types.
Any idea why this would be? I have the following:
* Version 3.1.4
* Subdomain network install
* Domain mapping plugin (if this matters)
Thanks. | I Found this forum article. It was an issue with the domain mapping and cookies. I ended up making sure the following options were both checked in the Domain Mapping options:
* Remote Login
* Redirect administration pages to site's original domain (remote login disabled if this redirect is disabled) | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "404 error, user roles, multisite, draft, previews"
} |
Using the same database on another Subdomain
Hi i am currently replacing my blog run on wordpress with another neat theme. I tried the preview template feature and everything is fine, just that i don't trust everything so easily when it comes to web-applications. So i want to use the same database currently used[meaning not to use same database for both sites, but make a copy of the database/something with the data/posts] with the post/article and then perfect the theme with the data then replace the old with new. I would like detailed steps for just the database part others i can handle :) thanks for any and every help | Just use the built-in exporter/importer. Export from the existing site, and import into the new site. You won't ever even need to touch the database. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "themes, database, templates, shared hosting, customization"
} |
Do you know a video plugin that allows embedding in the home.php file?
I've been looking for a video plugin in the plugin depository but couldn't find one that I'm looking for.
Basically, I want visitors to be able to play the video in the home page but the issue here is that the home page is displaying post excerpts. So if I would just post the video as normal, it would be cut in the home page.
So I think I would need to hard code the video code of the plugin inside the loop in the home template file, like where $video is the the video file in the post.
Does anybody know a video plugin like this?
Or is there a work around here, like how to show video in the home page having post excepts.
Thanks. | The excerpt is not meant for content that is why it is called "the excerpt".
Instead use a plugin like "Vipers Video Quicktags" or "Youtube shortcode" and add it to a template file and you'll probably want to get the url via a post meta field.
for example ( using Youtube shortcode plugin and meta field called "video"):
$video = get_post_meta($post->ID, 'video', true);
echo do_shortcode('[youtube_sc url='$video']'); | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "plugins"
} |
Migrate DB Plugin: Error "The directory needs to be writable"
I'm using the migrate db plugin to do some find and replaces to the database after it's been exported.
It continues to pester me with the directory isn't writeable error. I've went and chmod'd the whole /wp-content folder with the following command:
`chmod -R 777`
which i know you're not suppoose to do; but it's driving me nuts. it still has the same silly error.
Does anyone know which folder it's asking to give the correct permissions? | Ended up just exporting via command line. Neither answers were appropriate for the situation. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugins, migration"
} |
How to order posts by descending comment count on taxonomy page?
This lists the posts in my custom taxonomy template page:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
How can I order those posts by comment count? | A friend helped me with a solution that I could place in my functions.php file:
add_filter( 'pre_get_posts', 'my_pre_get_posts' );
function my_pre_get_posts( $query ) {
if ( is_tax( 'locations' ) && empty( $query->query_vars['suppress_filters'] ) )
$query->set( 'orderby', 'comment_count' );
return $query;
} | stackexchange-wordpress | {
"answer_score": 6,
"question_score": 3,
"tags": "query posts"
} |
Easiest way to show total number of subpages
I am making a portfolio site where each portfolio entry is a subpage of "Work". In my template, I am trying to say something like: worked on 15 projects and counting, where 15 is the total number of subpages.
Whats the easiest way to do this? | Use the following code, replacing the number after "child_of=" to the id of the parent page.
<?php
$count = 0;
$pages = get_pages('child_of=681&depth=1');
foreach($pages as $page) {
$count++;
}
echo $count;
?>
Reference: get_pages | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 2,
"tags": "php, templates, loop, page template"
} |
Different Template based on HTTP Referer
He Guys,
i've been looking for a way to show a different Page-Template based on HTTP Referer or maybe the User Agent or what ever.
I'm planning an Image-Gallery which should be shown in a Fancybox. My Idea is to use a template which contains only the `loop` and all the stuff i need to build the gallery correctly (without any Header and Footer files) and load it in my Fancybox.
But what about the Search Engines und Users with disabled JavaScript. They don't see anything or only a page without the Pagecontext like Navi etc. How can i prevent this issue?
Any ideas | Fancybox has built in fallback, it displays images without JavaScript.
I don't see why you would want to remove the header ( or footer) since it usually contains some good info like your doctype, css, meta, title, etc.
If you want it to look different ( aka strip it clean) you should still include it and use conditionals for your "Portfolio" page. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 1,
"tags": "templates, template redirect"
} |
How to change the category in URL for posts in multiple categories?
How can I change the category slug that appears in the URL of a post that's in multiple categories? I'd like to change the default WordPress behaviour of using the category with the lowest id.
I thought this would do it:
add_filter('post_link', 'mspc_post_link', 1, 2);
function mspc_post_link($link, $post) {
if (strpos($link, 'bad-category-slug')) {
$cats = get_the_category($post->ID);
foreach ($cats as $cat) {
if ("Bad Category Name" != $cat->cat_name) {
$slug = $cat->category_nicename;
break;
}
}
$link = str_replace('bad-category-slug', $slug, $link);
}
return $link;
}
But while this kind of does work as expected, it doesn't change the URL visible to user. | Similar plugin but compatible to latest wp version 3.5.2
<
> This plugin allows you to select a 'main' category for your posts, for better permalinks and SEO. It uses the same meta data as the "Hikari Category Permalink" and the "sCategory Permalink", but it has been rewritten using better and cleaner code.
>
> Requires: WP 3.5 or higher Compatible up to: 3.5.2 Last Updated: 2013-4-18 | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 4,
"tags": "categories, permalinks"
} |
Any easy way to automatically set the first inline image in a post as the thumbnail?
Is there a plugin for this? Has anyone done it before? | I use the Auto Post Thumbnail plugin for doing just that on this site and it works fine. First image in a post becomes the featured image every time. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 4,
"tags": "images, post thumbnails"
} |
What is best forum script available to integrate with wordpress?
Ok i have a wordpress site network. I would like to setup a support forum for my site. But i don't want users to signup in different pages. I mean i want my users to use the same wordpress login credentials in forum too. Is there any forum plugin available there. Thanks
PS: Is it possible using bbpress? | take a look at Mingle Forum plugin, which is nice, simple and did the job for me on a couple of sites.
also bbPress looks promesing but its still in a beta stage like @Rarst pointed out.
and last you have SimplePress which is by far the most feature rich forum plugin I've seen. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "multisite, bbpress, forum"
} |
Not able to export large no. of posts in csv
I have custom post type `product` like wp ecommerce.
There are 30k posts in it. Also have relate custom taxonomy. Basically am trying to export those posts in csv, but query_posts with so many records is giving me trouble...
Any tips??? | WordPress query mechanism drag whole set of results into memory so they are not suited for such large chunks of information.
You can use `numberposts` and `offset` in `get_posts()` to split process into chunks. I am not sure if you will be able to do it in single run even then, so you might need to save how many chunks you processed and start from there next time. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "custom post types, custom taxonomy, query posts, export"
} |
Is it possible to remove this action? (as it's added just before it's called)
In wp-signup.php there are these lines:
add_action( 'wp_head', 'wpmu_signup_stylesheet' );
get_header();
I need to remove `wpmu_signup_stylesheet` from the `wp_head` action, but I seem to be struggling, I assume it is because the action is being called straight after.
Here is what I've tried from a plugin:
// Called from an action that is added with:
// add_action('wp_head', array($this, 'remove_signup_style', 11));
remove_action( 'wp_head', 'wpmu_signup_stylesheet'); | The action is not right after actually. There is `get_header()` call, then `get_header` action and then locating and loading template file that has `wp_head()` in it.
I try not to mess with removing things from inside of same hook you are at, so in this case I'd (ab)use that `get_header` action to hook function that will remove what you don't want from later `wp_head`. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 2,
"tags": "plugins, hooks, actions"
} |
Force plugin to fail activation
I'm writing a plugin that will be using custom fields added by a theme.
Because of this, it would be ideal if my plugin not be able to activate should these fields not exist.
How do I go about displaying an error and forcing the activation to fail? | Code like this can do the trick.
function plugin_activation_check(){
if ( some_check_here() ) {
// this is the fail case
deactivate_plugins(basename(__FILE__)); // Deactivate ourself
wp_die("Message to user.");
}
}
register_activation_hook(__FILE__, 'plugin_activation_check'); | stackexchange-wordpress | {
"answer_score": 6,
"question_score": 2,
"tags": "plugins, plugin development, errors, activation"
} |
Why does WordPress require a ftp server to be running on the webserver to transfer plugins?
I had asked a related question on Super User:
> A use case of a system "receiving" files over FTP would be, for example, the way WordPress plugins are installed via 1-click where WordPress initiates a file transfer to the local Linux box from the remote WordPress plugin repository using ftp(s)
More specifically this screen:
!WP asking for ftp info during plugin install
My initial understanding that WordPress would transfer the files from the WordPress plugin repository, like how a FTP client would do. But further discussions on chat have left me confused as to why would WordPress require the FTP details of the web server?
What am I missing here? | When you do something that requires WordPress write to the filesystem, it does a check to see if it has permissions to do so by writing a temp file. If this check fails it will ask for FTP details in order to write the files to your server.
**EDIT**
look in `wp-admin/includes/file.php`, line 843, for the `get_filesystem_method` function that does this check. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 5,
"tags": "plugins, wp admin, ftp"
} |
/%post_name%/ or /%postname%/ in Permalinks?
In Settings-->Permalinks is there any difference between:
checking Custom Structure and using:
/%post_name%/
or
/%postname%/
Are they both correct? Will they both work?
Thank you.
-Laxmidi | `/%postname%/` is the correct one and if you are asking be cause it says post_name in the codex then its just to show that you will get the actual post name. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "permalinks, options"
} |
Adding fields to the "Add New User" screen in the dashboard
I'd like to add the field "Company Name" to the add new user page in the admin panel. I've done quite a bit of searching and have been unable to find details on how to do this. I can easily add info to the profile page and registration with..
function my_custom_userfields( $contactmethods ) {
//Adds customer contact details
$contactmethods['company_name'] = 'Company Name';
return $contactmethods;
}
add_filter('user_contactmethods','my_custom_userfields',10,1);
But no dice on anything else. | In order to do this you'll have to manually change the user-new.php page. It's not the correct way to handle it but if you're in desperate need this is how it's done.
I added
<tr class="form-field">
<th scope="row"><label for="company_name"><?php _e('Company Name') ?> </label></th>
<td><input name="company_name" type="text" id="company_name" value="<?php echo esc_attr($new_user_companyname); ?>" /></td>
</tr>
I also added the information to functions.php
function my_custom_userfields( $contactmethods ) {
$contactmethods['company_name'] = 'Company Name';
return $contactmethods;
}
add_filter('user_contactmethods','my_custom_userfields',10,1); | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 14,
"tags": "functions, wp admin, users, user meta, user registration"
} |
Making a 1140px wide header logo in the twenty-ten theme?
I've created a child theme that is a wide version of twenty-ten, and it is working for the most part. But I am struggling to make the header logo wider. You can see the work in progress here at <
The CSS that is not working is (it still shows as 980px):
#branding {
margin: 0 auto;
width: 1140px;
}
I can see that the generated html for the logo div is:
<div role="banner" id="branding">
<img width="940" height="198" alt=""
src="
</div>
And that header.php defines the logo like so:
<img src="<?php header_image(); ?>"
width="<?php echo HEADER_IMAGE_WIDTH; ?>"
height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
But I can't see where to set `HEADER_IMAGE_WIDTH` and `HEADER_IMAGE_HEIGHT`.
The CSS file is here: < | in your theme's functions.php, look for this:
// The height and width of your custom header. You can hook into the theme's own filters to change these values.
// Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );
Its best to creat a child theme, so you don't loose your customization when you next update WP/theme. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": -1,
"tags": "theme twenty ten, css, headers, logo"
} |
How to change Post ID during import
I'm importing posts from a Joomla v1.5 site using < (The goal is to clone the site in WordPress then switch off Joomla)
On both sites the permalink structure is /%category%/%post_id%-%postname%/
Of course, when I import I am getting a different post ID in WordPress than existed in Joomla.
Can I change post ID manually in the DB after import? Aside from .htaccess file with a huge number of rules (one per article!) is there another workaround for this issue? Any comments/suggestions?
Thanks, Alastair. | `wp_insert_post()` function in WP accepts special `import_id` field in arguments and will try to use that ID, rather than automatically generating new one.
This is easy to use when writing import code yourself, but I have no idea how easy would it be to with that plugin. You could try suggesting this as a feature to plugin's eveloper. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 1,
"tags": "permalinks"
} |
Author page like wordpress answers
I'm newbie in wordpress. I want to implement a page like < But no idea how to implement. The user listing, info, avatar,user search everything will same. any idea about the issue??? | Take a look at Members List Plugin
> The Members Plugin allows you to create a post on your wordpress blog that lists all your wordpress members. When viewing the list of members you can also search through your members according to first name, last name, email address, URL or any other number of user meta fields you may specify. Employing pagination you can page through your search results and sort your results according to last name, first name, registration date, email or any other field you may specify
I'm currently using it in a project and it works great. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "pages, users"
} |
Custom fields for custom post types
I have a custom post type for portfolio. To create one, you need to create a page with a particular template that i'm making, named page-portfolio.
Now, a portfolio post has custom fields as well. But, how can i make a custom field that is displayed in the post only if i select the 'portfolio' template ? That is, a custom field tied to the usage of the portfolio template ? | This is confusing you're mixing up the terminology of WordPress. A custom post type acts like a _post_ and not a _page_. If you have a custom post type called "portfolio" and use the proper template hierarchy, you don't have to do anything special. But you will need to name it `single-portfolio.php` and not `page-portfolio.php`.
<
<
If on the other hand, if you simply want to use "page" templates ( I think that is what you mean) you will need to write a conditional to display the post meta for only the `page-portfolio.php`.
The logic is along the lines of:
if (is_page_template('page-portfolio.php'))
the_meta();
Your default page most likely already has `the_meta();` though so you will most likely want to use `get_post_meta` or `get_post_custom` so you can have fields specific to your "portfolio".
ps. It's much easier to just use a custom post type (not a page template) for this sort of thing .
<
< | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "theme development"
} |
How to display posts by current user/author in a custom page template?
I am a trying to create a dashboard like custom page template that list post of of the current logged in user. I've tried to find a solution on the net. but none were appropriate | this should work for you:
if ( is_user_logged_in() ):
global $current_user;
wp_get_current_user();
$author_query = array('posts_per_page' => '-1','author' => $current_user->ID);
$author_posts = new WP_Query($author_query);
while($author_posts->have_posts()) : $author_posts->the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php
endwhile;
else :
echo "not logged in";
endif; | stackexchange-wordpress | {
"answer_score": 9,
"question_score": 3,
"tags": "posts, query posts, author, get posts, listing"
} |
Using add_theme_support inside a plugin
I've created a custom post type as a plugin and released it into the repository. One of the core features involves using a featured image. I've added `thumbnail` to `$supports` in `register_post_type()`, so the meta box shows up in the Administration Panel. I'm also hooking into `after_setup_theme` and calling `add_theme_support( 'post-thumbnails' )`, but I don't think it's taking affect.
The codex says you have to call it from the theme's functions.php file, but if that's true then it'll only work if the user's theme calls `add_theme_support( 'post-thumbnails' )` (which would cover _all_ post types. If the theme doesn't call it, or only calls it on a specific type, then it won't work.
Does anyone see a way around this problem? | There are comments in core code that this should be improved, but they are there for a while already. Basically there is no native function to add or remove _part_ of some feature, only feature altogether.
Doing it manually would be running something like this after theme is done (late on `after_setup_theme` hook):
function add_thumbnails_for_cpt() {
global $_wp_theme_features;
if( empty($_wp_theme_features['post-thumbnails']) )
$_wp_theme_features['post-thumbnails'] = array( array('your-cpt') );
elseif( true === $_wp_theme_features['post-thumbnails'])
return;
elseif( is_array($_wp_theme_features['post-thumbnails'][0]) )
$_wp_theme_features['post-thumbnails'][0][] = 'your-cpt';
} | stackexchange-wordpress | {
"answer_score": 9,
"question_score": 7,
"tags": "custom post types, plugin development, post thumbnails"
} |
How do I add e-mail subscription functionality
Hi I am new to wordpress. Kinda going through different themes that is available. I like on, which is Oulipo, but it doesn't have any e-mail subscription feature. I am using free wordpress hosting.
I know may be this question is too silly but I don't understand how to add it. As I have heard free word press hosting don't have many features available, so I was wondering if only the allowed features are those that comes with the theme or is it customizable further?
Thanks. | Many plugins currently available allow you to enable this feature on your site. My favorite is Jetpack Subscriptions for reasons including:
* Very much up-to-date, well-maintained plugin
* Emails sent from WordPress.com servers, so there's absolutely no load on your servers
(Make sure you disable all the unnecessary modules activated by default when you activate Jetpack by WordPress.com plugin.)
If you want the emails to be sent from your servers, I think you'd be better off using Subscribe to Comments or Subscribe To Comments Reloaded—whichever suits you best. | stackexchange-wordpress | {
"answer_score": 3,
"question_score": -1,
"tags": "functions"
} |
New User Sessions in Wordpress?
Is there any way to create a simple user session on Wordpress, like a mini-membership kind of thing? Would this conflict with WP's general user sessions, or is it possible to set up a simple uesr/pass combo in your database and use this to create a sub-membership system? | Instead of forcing Wordpress to have a custom membership system, if you want to use your own small membership feature, then you may not have to use sessions at all.
For instance, if you want to password protect a specific set of pages, you could make one page require authentication, using a username and password like you mention. Once the user has accessed this page, validated by the database of users separate from wp_users, you can use ajax to keep this "session" (or appearance therefore) alive. That way you achieve your needed functionality without having to program something that kind of goes against the nature of the Wordpress system. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "membership"
} |
Find Page Last Modified at Certain Date & Time
How can I find the page which was last modified on 2011-07-20T20:48:16+00:00 other than opening every page? | Okay, I've got it.
I looked in wp_posts table in phpmyadmin, clicked on the post_modified column to get it in chronological order, and looked for the appropriate datetime. | stackexchange-wordpress | {
"answer_score": -1,
"question_score": 0,
"tags": "pages"
} |
How to display serial numbers in foreach loop while querying posts?
Ok, I have a custom post type to store list of urls. I would like to print those urls with serial numbers. I used foreach loop.
foreach($urls as $url){
echo $url;
I got n number of urls as output. But i want to print serial numbers in each url like 1,2,3 and so on. I don't want to use unordered list. Because i want to style my serial numbers too. So is there any way to print serial numbers? | How about:
echo '<ul>';
$sn_count = 1;
foreach($urls as $url){
echo '<li><span class="serial-number">'.$sn_count.'</span> '.$url .'</li>';
$sn_count++;
}
echo '</ul>';
You can then style your serial numbers with the `serial-number` class. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": -1,
"tags": "custom post types"
} |
How do I add a timezone offset to this query?
Problem is that $today is pulling GMT from the database; I need to offset GMT by -6 hours; Have been unable to find a query with an offset like that.
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$today = date('Y-m-d');
query_posts(array(
'post_type' => 'performance',
'posts_per_page' => 4,
'caller_get_posts' => 4,
'paged' => $paged,
'meta_key' => 'order-date',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'order-date',
'meta-value' => $value,
'value' => $today,
'compare' => '>=',
'type' => 'CHAR'
)
)
));
if (have_posts()) :
while (have_posts()) : the_post();
?> | Is WP set to that -6 offset you need? In that case try `date_i18n()` to generate your date instead of `date()`. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "query posts, offsets"
} |
wp_set_post_terms example?
My client has a post type that uses a lot taxonomies. I plan to put this script in a post meta box and hide the existing taxonomies.
**Do you know of a greatwp_set_post_terms example?**
I want to make this:
!enter image description here
Look like this: !enter image description here
Related functions? wp_update_term | Name your fields like `car_specs[taxonomy_name]`, then within "save_post" just do:
foreach($_POST['car_specs'] as $tax => $term)
if(taxonomy_exists($tax)) // && term_exists($term, $tax)
wp_set_post_terms($post_id, $term, $tax);
Personally I wouldn't use WordPress for a auto classifieds type of website. There are PHP frameworks out there better suited for building such sites | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "custom taxonomy, wp admin"
} |
Show limited menu to admin
I am using the latest wordpress 3.2.1. I would like to let create a new admin to do ONLY this: 1) Manage order to change the order status to (e.g. approve..reject). 2) Able to view user only without the ability to Edit or Delete. 3) Accept email notification on new registered user and new order.
This would meant that when this new admin login, he is able to view only these 3 menu and All other menu will be invisible. Could anyone advice? I have tried many like the Adminimize, Admin Menu Editor, hide-admin-panels.. But all don works as it is a role based instead of user based.
Should i create a new `admin` for these features above? or should i create an `editor` instead ? Then change the menu for editor.. I need your advice. thanks | Try this plugin: < | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "admin menu, e commerce"
} |
Share DB tables between two blogs on the same WP Multisite installation
Is it possible for two separate blogs running on the same multisite installation to share tables in the database?
By default, Wordpress adds the blog ID to the table prefix for all of the associated tables such that blog #1's posts are stored in the `wp_1_posts` table, blog #2's posts in the `wp_2_posts` table etc..
However, for my peculiar development workflow I would like to use blog #1 for public use and blog #2 for development while sharing database tables between them such that any changes made to either blog are reflected on both immediately (i.e. **both** blog #1 and blog #2's posts are stored in `wp_1_posts`, their users in `wp_1_users`, and so forth).
Any ideas? | You can switch back and forth between blogs on a multisite with `switch_to_blog` and `restore_current_blog`.
That should allow you to get anything you'd like and make queries as if you were actually on the other blog.
Check them out: < <
We did a **lot** of this with one of our recent sites. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 1,
"tags": "multisite, database"
} |
How to receive notification of deprecated API elements and functions?
There is some way to get notifications when deprecated API elements are used in WordPress. How is it done? Put WordPress in debug mode (which also shows all other types of errors) or is there another method that shows only API related errors? | Just install the Log Deprecated Notices plugin. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugin development, wp debug, deprecation"
} |
Development plugin to view and manage scheduled wordpress cron jobs?
Is there a plugin for wordpress that can help a user to view and manage the crons that are currently schdeuled in WordPress? I have looked into Core control but doesn't allow the user to manage the cron jobs. | WP-Crontrol.
< | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "plugin development, plugin recommendation"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.