yoshi
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Image in excerpt = permalink to post wont work?You need to print the value.
<a href="<?php the_permalink(); ?>"><?php echo strip_tags(get_the_excerpt(),'<img>'); ?></a>
Forum: Plugins
In reply to: Help Me Develop a PluginIs your plugin file digg_this.php?
‘activate_filename.php’ in the hook must meets the actual file name.Try echo something in the function to see if the function is really being called.
function diggurl_addcolumn () {
die ('hook called');
...Forum: Plugins
In reply to: Hide posts from specific categoryYou can easily control what to show in the page using the ‘query_posts’ template tag.
In your template, before the loop begins, place
<?php if(is_home()) {query_posts('cat=-5');} ?>
where the ‘-5’ is the ID of the category you don’t want to include in the listing.
See
https://codex.www.ads-software.com/Template_Tags/query_posts
for more details on query_posts.Forum: Themes and Templates
In reply to: Custom Fieldsget_post_meta()
doesn’t echo likethe_meta()
.
You need to print the returned value.echo get_post_meta($post_id, 'sub-banner', true);
Forum: Plugins
In reply to: Help Me Develop a Plugin<img src="<?php echo get_settings('siteurl') ?>/wp-content/plugins/myplugin/img.png" />
Something like this?
Forum: Plugins
In reply to: Help Me Develop a PluginHi ehmcgregor,
‘activate_diggthis.php’ is not a external file but the ‘activate_’ hook, which is called when plugins are activated.
If your plugin file is myplugin.php, you can add action like:
add_action('activate_myplugin.php','myplugin_install');
then the function
myplugin_install()
will be executed on plugin activation. You can create column here.And as you can guess, ‘disactivate_’ hook is for disactivation. You can remove some options or custom database table if needed.
Here is a list of wp hooks.
https://wphooks.flatearth.org/Forum: Plugins
In reply to: Help Me Develop a PluginOops. my show_digg_this() had error didn’t it. Sorry I wasn’t actually testing my code.
This time I checked this working.
function show_digg_this ($id = 0) {
global $post; // changed.
$diggurl = $post->digg_url;if ( strlen($diggurl) > 0 )
echo $diggurl;
else {/* the_permalink() echos the url. use get_permalink() to get as valiable. */
$digg_permalink = get_permalink($post->ID);/* you can't use valiables within single quotes */
echo '<div id="digg_this_button"><a href="https://digg.com/submit?phase=2&url=' . $digg_permalink . '" title="Add to Digg"><img src="digg_button.gif" alt="Digg Button" /></a>
</div>';
}
}Forum: Plugins
In reply to: Help Me Develop a Plugin1)
add_action('wp_digg_this', 'diggurl_insert_post');
this should be
add_action('wp_insert_post', 'diggurl_insert_post');
I have not read through your code carefully so there might be somewhere else to fix. If it still doesn’t work please try my original code and let me know if it works.
2) The simplest one would be something like:
function show_digg_this () {
$post = &get_post();
$diggurl = $post->digg_url();
if ( strlen($diggurl) > 0 )
echo '<a href="' . $diggurl . '">' . $diggurl . '</a>';
}
And you can call <?php show_digg_this (); ?> in your template.
Again, don’t forget to add some validation at submission and display(especially if you allow users to post).
Regards,
// can anyone let me know how to indent within the code?
Forum: Plugins
In reply to: Help Me Develop a PluginI don’t know why just using custom field isn’t good enough.
However, if for any reason you REALLY need it in the wp_posts table, try this.
posturl.php ==================================
<?php
/*
Plugin Name: posturl
Plugin URI:
Description:
Author: Yoshi
Version: 0.5b
*/add_action('wp_insert_post', 'posturl_insert_post');
function posturl_insert_post($pID) {
global $wpdb;extract($_POST);
$wpdb->query(
"UPDATE $wpdb->posts SET
post_url = '$post_url'
WHERE ID = $pID");}
add_action('dbx_post_sidebar', 'posturl_addfield');
function posturl_addfield() {
global $post;
?>
<fieldset id="posturl" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Post URL'); ?>:</h3>
<div class="dbx-content"><input name="post_url" type="text" size="13" id="post_url" value="<?php echo $post->post_url ?>" /></div>
</fieldset><?php
}add_action('activate_posturl.php', 'posturl_addcolumn');
function posturl_addcolumn () {
global $wpdb;
$wpdb->query("ALTER TABLE $wpdb->posts ADD COLUMN post_url varchar(128)");
}
?>=============================================
And post_url can be called like <?php echo $post->url ?> in your template.Should have url validation and display function but don’t have time right now…
Forum: Fixing WordPress
In reply to: do child categories inherit template of parent category?I wanted to do the same thing and made plugin like this.
add_action('template_redirect', 'inherit_cat_template');function inherit_cat_template() {
if (is_category()) {
$catid = get_query_var('cat');
if ( file_exists(TEMPLATEPATH . '/category-' . $catid . '.php') ) {
include( TEMPLATEPATH . '/category-' . $catid . '.php');
exit;
}$cat = &get_category($catid);
$parent = $cat->category_parent;
while ($parent){
$cat = &get_category($parent);
if ( file_exists(TEMPLATEPATH . '/category-' . $cat->cat_ID . '.php') ) {
include (TEMPLATEPATH . '/category-' . $cat->cat_ID . '.php');
exit;
}
$parent = $cat->category_parent;
}
}
}In category page this look for ‘category-XX.php’ template and if it doesn’t exist look for the parent cat’s template and so on. And if no category template to the top level cat, then it goes back to normal template hierarchy.
Forum: Plugins
In reply to: Image Upload Hack for Multiple Images?Looks like the ‘a’ tag was parsed. Didn’t notice.
Here is the code again.
<?php
/*
Plugin Name: Check Image Dementions
*/add_action ('add_attachment', 'rx_check_image_dimentions');
function rx_check_image_dimentions($post_ID) {
$maxwidth = 450;
$maxheight = 250;$post = & get_post($post_ID);
if ( preg_match('!^image/!', $post->post_mime_type) ) {
$file = get_post_meta($post->ID, '_wp_attached_file', true);
$imagesize = getimagesize($file);
if ( $imagesize['0'] > $maxwidth || $imagesize['1'] > $maxwidth ) {
wp_delete_attachment($post_ID);
die("Image must be smaller than $maxwidth x $maxheight !!!" . '<br /><a href="' . $_SERVER['HTTP_REFERRER'] . '?action=upload&post=' . $post->post_parent . '">'.__('Back to Image Uploading').'</a>');
}
}
}
?>Forum: Plugins
In reply to: Image Upload Hack for Multiple Images?MPM, maybe you can do something like this.
=========================================
<?php
/*
Plugin Name: Check Image Dementions
*/add_action ('add_attachment', 'r_check_image_dimentions');
function r_check_image_dimentions($post_ID) {
// chenge these
// ============
$maxwidth = 450;
$maxheight = 250;$post = & get_post($post_ID);
if ( preg_match('!^image/!', $post->post_mime_type) ) {
$file = get_post_meta($post->ID, '_wp_attached_file', true);
$imagesize = getimagesize($file);
if ( $imagesize['0'] > $maxwidth || $imagesize['1'] > $maxwidth ) {
wp_delete_attachment($post_ID);
die("Image must be smaller than $maxwidth x $maxheight" . '
post_parent . '">'.__('Back to Image Uploading').'');
}
}
}
?>
=========================================Forum: Plugins
In reply to: Image Upload Hack for Multiple Images?I wanted the same feature and hacked inline-uploading.php to arrow multiple files and I changed it to a plugin
It’s very simple but if you JUST need multi-files feature, this would help.
wordpress.ex-libris.jp/200604/inline-multiple-uploading/
Currently it’s only been tested with FF+Win2000.
If using other browsers, pls forgive me for potential bugs.
Testers are always welcome:).Forum: Fixing WordPress
In reply to: multiple sites, same users – how?If you are seeing “don’t have permission” error after logged in, you provably have missed this part.
In the wp2_options table in the database,
look for an entry with wp2_user_roles in option_name column.
Change this to wp_user_roles.If you have manipulated caps&roles using plugin this would be tricky though.
Forum: Fixing WordPress
In reply to: multiple sites, same users – how?Here is my answer with wp2.
1st blog’s table prefix : ‘wp_’
2nd blog’s table prefix : ‘wp2_’
Both in the same DB.Step 1:
After installation, in the 2nd blog’s wp-settings.php, around line 87,
change
$wpdb->prefix = $table_prefix;
to
$table_prefix = 'wp_';
$wpdb->prefix = $table_prefix;
$wpdb->users = 'wp_users';
$wpdb->usermeta = 'wp_usermeta';
Step 2:
In the
wp2_options
table in the database,
look for an entry withwp2_user_roles
inoption_name
column.
Change this towp_user_roles
.That’s it. This seems to be working for me.