Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

GeneralHavok on "Add input to Comment form"

$
0
0

Need a hand. I'm not a noob, but I'm puzzled by the instructions/tutorials I've found for customizing a WP comment form.

Quite simply, I want to add an input to the comment form. Seems like the following is needed:

1. Add the input (and label) to the form.
2. Store the data in the database, requiring a new field.
3. Retrieve the data for display on posts.
4. Add the data to the Admin for viewing/editing.

Could somebody lay out, in simple terms, how this is done? Again: I've read EVERYTHING I can find on this, but the info is either outdated or I don't understand it.

Thanks for your help!


fireflip on "Relate Images to Posts, Advice?"

$
0
0

Hey!

Can anyone point me in a direction to the best way to dynamically relate images to a post?

I would like to be able to upload images using the media library, tag the images with an assortment of tags and then have those images show up on posts that match those tags.

So for instance if a post is titled "Holiday" it will display all images that have been tagged with "holiday".

Any pointers will be greatly appreciated,
Thanks!

maxgoldberg on "if someone modifies a premium theme can they then re-sell them / give them away?"

$
0
0

Are themes covered by gnu? What about plugins? Or is it just the core?

onerock on "Custom Search Function for plugin update"

$
0
0

I am relatively new to WordPress and have never coded a plugin. I thought that this would be a great place to get my feet wet. :)

I am working to update the "NextGEN Gallery Search" plugin (http://wordpress.org/plugins/nextgen-gallery-search/) that appears to have been abandoned since it has not been updated in over 2 years and the authors website is gone. It allows you to find the gallery you are looking for without browsing all the admin galleries pages.

NextGen Gallery 2.0 is currently in beta and this plugin doesn't work any longer. I rely on the functionality of this plugin, so I have corrected most everything. I am getting stuck with the search portion of it.

The plugin has the following code

<form method="post" action="<?=$_SERVER['REQUEST_URI']?>">
<table class="form-table" style="width:570px;">
<tr valign="top">
<th scope="row"><label for="ngs2_filter">Search Keyword</label></th>
<td><input name="ngs2_filter" type="text" id="ngs2_filter" value="<?=$_POST['ngs2_filter'];?>" class="regular-text" /></td>
<td><input type="submit" name="Submit" class="button-primary" value="Search" /></td>
</tr>
</table>
</form>
$gallerylist = ngs2_search_galleries($_POST['ngs2_filter']);

With the code above, when you visit the admin page <?=$_POST['ngs2_filter'];?> appears in the search box. If you attempt a search, you receive a "404 Not found" with the address bar showing "192.168.0.105/wp-admin/<?=$_SERVER['REQUEST_URI']?>"

I have attempted to follow the WordPress Codex (http://codex.wordpress.org/Function_Reference/get_search_form), but it doesn't explain the various varialbe the plugin seems to use.

Can someone please advise me on what might be the issue with the above code or point me in the direction of information that will further explain how to fix this?

I am unable to post a link as it is on a dev server without inbound service.

The function works correctly on Wordpress version 3.5.2 and current version 1.9.13 of Nextgen Gallery.

Thanks so much in advance
Scott

pieterw3 on "Div around Comment text"

$
0
0

Hello, i would like to have a div around my comment text. the current setup is a <p> around the comment text. i found that i might need to edit the wp_list_comments() but i have not been able to find it. can someone point me to the right file to edit?

my theme is responsive. and my site is http://itsolutionsblog.net i am already using a child theme.

wilirius on "Uploaded image is being resized to the same size as full"

$
0
0

When I upload an image of say size 940x300 it is being resized by wordpress with the extension 940-300. This is completely unnecessary and also creates a worse image because the full size image IS already that size and optimized.

I was pretty sure that WP did not create this redundancy, yet I am witnessing it in the most recent theme I am using.

I am also using wp_get_attachment_image_src as it is the command which is searching for the image and returning the one with the extension.

THE MOLITOR on "Publish scheduled/future posts in 3.5"

$
0
0

Hi there,

I'm using the following code in my functions.php file that sets posts with a future publish date to the "published" status (instead of "scheduled").

Everything worked perfect until updating to WordPress 3.5. Does anybody know why?...

function setup_future_hook() {
 // Replace native future_post function with replacement
 remove_action('future_post', '_future_post_hook');
 add_action('future_post', 'publish_future_post_now');
}

function publish_future_post_now($id) {
 // Set new post's post_status to "publish" rather than "future."
 wp_publish_post($id);
}

add_action('init', 'setup_future_hook');

mrfraz on "get last comments | with pop-up link"

$
0
0

hey,

i found a code snippet for last comments on a static page:
but i use comments only with a pop-up.

<?php comments_popup_link('0 Comments', '1 Comment',
'% Comments', 'comment-link-top', 'Comments closed.'); ?>

could anyone help me to use the pop-up-link above in the code?
that would be great :-)

<?php
$comments = get_comments('status=approve&number=5');
  foreach($comments as $comment) :?>

  <?php $my_id = $comment->comment_post_ID ; $post_id_comms = get_post($my_id); $title = $post_id_comms->post_title;?> 

    Who: <?php echo($comment->comment_author);?><br />
    About: <a href="<?php echo get_permalink($my_id) ?>#comment-<?php echo $comment->comment_post_ID?>" title="on <?php echo $title ?>"><?php echo $title ?></a><br />
    What they said: <?php echo($comment->comment_content);?><br />
    When they said it: <?php echo($comment->comment_date);?><br />

  <?php endforeach;?>

hungken on "Only display featured image of the first post"

$
0
0

I want to know how to displayed random post like image below:

http://i.imgur.com/ejNRh1e.png

That is, the code will display a list of 8 random posts, but only show the first post featured image and post excerpts of it. the next post will show the title and nothing else

Please give me the code to do this! I use it to insert a widget supports PHP, If possible, please include simple css

Thanks for your help!!!!

(Sorry for my english)

vimes1984 on "widgets admin page and js inside widget..."

$
0
0

Ok so here's the question:
I have registered a custom widget inside of my functions.php, the widget has custom js inside it the code is as follows:

/*
*
*Ajax loaded gallery for sidebar
*Note tis will not work cross browser.
*
*
*/
/**
 * Plugin Name: A gallery Widget
 * Description: A widget that displays an ajax loaded gallery.
 * Version: 0.1
 */

add_action( 'widgets_init', 'my_widget' );

function my_widget() {
  register_widget( 'MY_Widget' );
}

class MY_Widget extends WP_Widget {

  function MY_Widget() {
    $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that displays the chosen gallery images and link from lundhs ', 'example') );

    $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' );

    $this->WP_Widget( 'example-widget', __('Reference Projects', 'example'), $widget_ops, $control_ops );
  }

  function widget( $args, $instance ) {
    extract( $args );

    //Our variables from the widget settings.
    $titlewidget = apply_filters('widget_title', $instance['titlewidget'] );
    $introtext = $instance['introtext'];
    $title = $instance['title'];
    $name = $instance['name'];
    $img = $instance['img'];
    $show_info = isset( $instance['show_info'] ) ? $instance['show_info'] : false;

    echo $before_widget;

?>
<?php
if($titlewidget)
  ?>

<h4 class="widget-title"><?php echo $titlewidget;?></h4>
<?php
if($introtext)
?>
<p> <?php echo $introtext; ?></p>
    <div class="row">
<?php
//display gallery img
if ( $img)
  ?>
<a class="columns four" href="<?php echo $name; ?>">
     <img class="imggallery" src="<?php echo $img; ?>">
   </a>
    <?php
  // Display the gallery name and link
    if ( $title )
      ?>
     <a class="columns eight imggallery_link" href="<?php echo $name; ?>"><?php echo $title; ?></a>

</div>

<?php
    echo $after_widget;
  }

  //Update the widget 

  function update( $new_instance, $old_instance ) {
    $instance = $old_instance;

    //Strip tags from title and name to remove HTML
    $instance['titlewidget'] = strip_tags( $new_instance['titlewidget'] );
    $instance['introtext'] = strip_tags( $new_instance['introtext'] );
    $instance['title'] = strip_tags( $new_instance['title'] );
    $instance['name'] = strip_tags( $new_instance['name'] );
    $instance['show_info'] = $new_instance['show_info'];
    $instance['img'] = $new_instance['img'];

    return $instance;
  }

  function form( $instance ) {

    //Set up some default widget settings.
    $defaults = array( 'title' => __('Example', 'example'), 'introtext' => __('introtext', 'example'), 'titlewidget' => __('Reference Project', 'example'), 'img' => __('img', 'example'), 'name' => __('link goes here', 'example'), 'show_info' => true );
    $instance = wp_parse_args( (array) $instance, $defaults ); ?>
<script type="text/javascript">
(function($) {

//load on page load
  $(".area").load("/galleries/ #projects > li a");

//load on widget title click
            $('.widget-top').live("click", function() {
             $(".area").load("http://nettsidemal.no/lundhsas/galleries/ #projects > li a");
            });

//stop default href from working
            $('.area a').unbind().live("click", function() {
                             event.preventDefault();
                             return;
             });
//load into input boxes
$(".area a").live("click", function() {
      var title = $(this).attr('title');
      $(".title").val(title);
      var link = $(this).attr('href');
      $(".link").val(link);
      var img = $("img", this).attr('src');
      $(".img").val(img);
      var imgexample = $("img", this).attr('src');
      $(".gallery_one").attr("src", imgexample);
    });
}(jQuery));
</script>
<style type="text/css">
.area img{
    max-width: 100px;
    max-height: 100px;
    display: inline-block;
}
.area a{
    max-width: 100px;
    max-height: 100px;
    display: inline-block;
}
.gallery_one_image_wrap{
  width: 100%;
height: 150px;
}
.gallery_one{
max-width: 80%;
max-height: 150px;
width: 80%;
margin: auto;
padding-left: 10%;
padding-right: 10%;
}
</style>
<script type="text/javascript">
(function($) {
        var addDiv = jQuery('.addinput');
        var i = jQuery('.addinput p').size() + 1;

    jQuery('.addNew').live('click', function() {
        jQuery.append('<p><input type="text" class="p_new' + i +'" size="40" name="p_new_' + i +'" value="" placeholder="I am New" /><a href="#" class="remNew">Remove</a> </p>');
        i + 1;

        return false;
    });

    jQuery('.remNew').live('click', function() {
          if( i > 1 ) {
          jQuery(this).parents('p').remove();
          i - 1;
          }
    return false;
    });
}(jQuery));

</script>
   <h3>Gallery selector for Lundhs</h3>
    <p>
    <label for="<?php echo $this->get_field_id( 'titlewidget' ); ?>"><?php _e('Widget Title:', 'example'); ?></label>
      <input type="text" class="titlewidget" name="<?php echo $this->get_field_name( 'titlewidget' ); ?>" value="<?php echo $instance['titlewidget']; ?>" style="width:100%;" />
    </p>
    <p>
    <label for="<?php echo $this->get_field_id( 'introtext' ); ?>"><?php _e('Intro text:', 'example'); ?></label>
      <input type="text" class="introtext" name="<?php echo $this->get_field_name( 'introtext' ); ?>" value="<?php echo $instance['introtext']; ?>" style="width:100%;" />
    </p>
      <h4 style="text-align: center;">First Pick your images</a>
    <div class="area"></div>

<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
    <h3>Your current front end projects</h3>
    <h4>Reference project one</h4>
    <div class="gallery_one_image_wrap">
    <img class="gallery_one" src="<?php echo $instance['img']; ?>" /><br/>
    </div>
    <p>
      <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'example'); ?></label>
      <input type="text" class="title" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
    </p>
    <p>
      <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('The link:', 'example'); ?></label>
      <input type="text" class="link" id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" value="<?php echo $instance['name']; ?>" style="width:100%;" />
    </p>

    //img Input.
    <p>
      <label for="<?php echo $this->get_field_id( 'img' ); ?>"><?php _e('The Link to the image:', 'example'); ?></label>
      <input type="text" class="img" id="<?php echo $this->get_field_id( 'img' ); ?>" name="<?php echo $this->get_field_name( 'img' ); ?>" value="<?php echo $instance['img']; ?>" style="width:100%;" />
    </p>
<div class="addinput">
<p>
<a href="#" class="addNew">Add new project</a>
</p>
</div>
  <?php
  }
}

the problem arises because the js runs twice once in the inactive widgets on the left and once in the active widget in the sidebar.
How do i go about forcing the JS to run only in the active widget.
Moving the js to a separate .js file and enqueing really isn't an option for me because i am going to have to use php values in the next step.
Any help is appreciated.
Chris

mrfraz on "Get Term-ID"

$
0
0
<?php

$meta = get_option('select_name');
if (empty($meta)) $meta = array();
if (!is_array($meta)) $meta = (array) $meta;
$meta = isset($meta['77']) ? $meta['77'] : array();
$value = $meta['select_field'];
echo $value; // if you want to show

?>

How can i replace the "77" with the current term id of the site?
Maybe someone can help me.

thank you!

Panagiotis Angelidis on "How to remove the comment form"

$
0
0

Hello
I am trying to remove the comment form from posts or pages without any success. The concept is via a plugin’s shortcode the users could remove the comment form. Any ideas of how this could be done?

Thanks
Panos

cscott5288 on "Adding a admin menu item that links to a URL"

$
0
0

I understand that I can add an admin link which links to a page generated by a specified function, but I just want to link to a URL (not a page generated by a function). Specifically, an Edit view of a particular page. So the admin menu link will essentially take you to Pages --> [Page Name] --> Edit. Is there a way to do this? I couldn't find it here: http://codex.wordpress.org/Administration_Menus

Thanks!

edw!n on "wp_dropdown_pages() with parents disabled"

$
0
0

I wnat to use wp_dropdown_pages() the get a select with all pages within the site. But for all pages that have children, I'd like the <option> to be disabled, because these pages don't have any content. They are there just for hierachial reasons.

So

<select >
	<option class="level-0" value="2">Home</option>
	<option class="level-0" value="8">Praktisch</option>
	<option class="level-1" value="53">&nbsp;&nbsp;&nbsp;Contact & Route</option>
	<option class="level-1" value="55">  Mission</option>
	<option class="level-1" value="57">  Who is who</option>
	<option class="level-0" value="12">Schrijfcoaching</option>
	<option class="level-1" value="63">  Schrijfcoaching</option>
	<option class="level-1" value="65">  Manuscriptbeoordeling</option>
</select>

should be

<select >
	<option class="level-0" value="2" disabled>Home</option>
	<option class="level-0" value="8">Praktisch</option>
	<option class="level-1" value="53">&nbsp;&nbsp;&nbsp;Contact & Route</option>
	<option class="level-1" value="55">  Mission</option>
	<option class="level-1" value="57">  Who is who</option>
	<option class="level-0" value="12" disabled>Schrijfcoaching</option>
	<option class="level-1" value="63">  Schrijfcoaching</option>
	<option class="level-1" value="65">  Manuscriptbeoordeling</option>
</select>

Is there a way to do this?

jamieschmid on "Help me brainstorm a way to sort the items in featured areas?"

$
0
0

Here is the setup:

I have a CPT Projects, and a taxonomy of Featured Areas.

Each project has a slideshow. I'm using an ACF repeater to set the slides on each project page. It works awesome, by the way!

Throughout the site, there are different sliders and "featured areas" where I am showing the first item in the project's slideshow.

To set these projects to be featured on the various places on the website, you tick the box in the Featured taxonomy. There's about 5 boxes for the various featured areas on the site. Ticking the box automagically makes the project show up in those place.

It works well, it's easy to use and intuitive and fast.
EXCEPT I forgot about "what if you want to rearrange the order these projects are listed in those featured areas?"

Good question.

I have a few ideas but want to see if anyone has a better idea. Anyone have any thoughts on how I could achieve this?


majestsick on "I made random redirect post on 404, but seo help please"

$
0
0

I have made my 1st php code and I think its amazing lol probably not, it goes to a random post but in a much better way if you go to a 404 on my website yont.co.uk and type some jiberish after a "/" you can see. (it doesn't show a random post as such, it redirect to a random post)

My problem is, does any one think it will mess my SEO up?

In functions.php I replaced:

if (theme_get_option('theme_show_random_posts_on_404_page')) {<br /> theme_ob_start();<br /> echo '<h4 class="box-title">' . theme_get_option('theme_show_random_posts_title_on_404_page') . '</h4>';<br /> ?></p> <ul> <?php<br /> global $post;<br /> $rand_posts = get_posts('numberposts=5&orderby=rand');<br /> foreach ($rand_posts as $post) :<br /> ?></p> <li><a>"><?php the_title(); ?></a></li> <p>	 <?php endforeach; ?> </ul> <p> <?php<br /> theme_post_wrapper(array('content' => theme_ob_get_clean()));<br /> }

with:

if (theme_get_option('theme_show_random_posts_on_404_page')) {<br /> $posts = get_posts('post_type=post&orderby=rand&numberposts=1');<br /> foreach($posts as $post) {<br /> $link = get_permalink($post);<br /> }<br /> wp_redirect($link,307);<br /> exit;<br /> }

The reason I ask is because I have never heard of anyone making a code like this and its probably for SEO reasons.

Ps: is my 1st code good? I have no idea what I am doing but some how works lol.

[No bumping, thank you.]

atomicfuze on "Including a page in multiple custom menu drop downs and both highlight"

$
0
0

I'm including a page in multiple top level custom menu items and both main menu items highlight when you visit the page.

Basically the last two main menu items are "Buy Now" and "Minting Process"

Under "Buy Now" is a link to "Minting Process" as well.

If you go to the "Minting Process" page both "Buy Now" and "Minting Process" highlight.

Any help is appreciated to not have them both highlight.

golfcoins.com

cheers,
-Brian

mrfraz on "echo wp_get_attachment_image"

$
0
0
foreach ($files as $att) {
 echo wp_get_attachment_image($att); }

Need a little help.. for if empty..
echo.. nothing.

Thanks!

tstrebeck on "Display menu for pages under specific directory"

$
0
0

Here's the basic structure of my site:

Section 1
- subpage
- - sub subpage
- - sub subpage
- subpage
- - sub subpage
- subpage

Section 2
- subpage
- - sub subpage
- - sub subpage
- subpage
- subpage
- - sub subpage
- - sub subpage

Section 3
- subpage
- - sub subpage
- - sub subpage
- subpage
- subpage

What I'm wanting to do is display is the first level of children of each section at the top level of that specific directory and for all the children underneath it. Is there some way to accomplish this? Will I need to create 3 different menus and then set up some sort of if/then scenario?

Thanks for your help!

kristarella on "wp_get_attachment_image_attributes filter not working"

$
0
0

I've seen this filter in a few places on the net and I've looked at the core WP code, as far as I can see this should work, but it doesn't work at all.

function remove_img_title($atts) {
	unset($atts['title']);
	return $atts;
}
add_filter('wp_get_attachment_image_attributes','remove_img_title',1,1);

Obviously I'm trying to remove the title attribute from images inserted to posts... I've also tried replacing the title with an arbitrary string, but that doesn't work either. I saw in another forum Q that their filter was only working for posts with feature images, so I tried featuring the image... still doesn't work.

Please help!

Viewing all 8245 articles
Browse latest View live




Latest Images