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

norhafidz on "Calendar for"

$
0
0

I want to develop an HRM solution using wordpress for my company, and I am looking for a plugin that can handle the leave management section (annual leave, sick leave, emergency leave).

I tried a couple of booking management plugin and event management plugin, however the nature of those plugin doesn't suit the requirement of the HRM system and process, for instance: booking and event management plugin allows only one date and they have time.

Does anyone know of any plugin that I can use for this purpose? Thanks!


jeriksson on "Catch multiple post images with catch_that_image in functions.php"

$
0
0

Hi,

I'm wondering if there's a simple way to catch multiple images by modifying this catch_that_images function in functions.php

function catch_that_image() {
  global $post, $posts;
  $first_img = '';
  ob_start();
  ob_end_clean();

  if( $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches) )
{
$first_img = $matches[1][0];
}

  if(empty($first_img)) {
    $first_img = "/placeholder.png";
  }
  return $first_img;
}

it currently only returns one image, how could i make it return 2 or more?

galenpharma on "Website Hack"

Jan Dembowski on "Please use How-To and Troubleshooting for compromised websites"

aus10 on "Image Upload Link Hack"

$
0
0

Hello world!

I am working on a site that features most posts with multiple pages.

I am trying to figure out where/how I would add an option to make a new option for the image link on uploads. I would like the option to have the image link to the next page in the post. I would think this could be done some how with the $page variable in a link but I am not sure where the options for the links are. I have looked in the JS files trying to find the uploader but no luck.

Any help is appreciated.

Guido on "Register shortcode necessary?"

$
0
0

Hi,

1) I can register a shortcode like this:

function register_shortcodes(){
	add_shortcode('knowledgebase', 'four_columns');
}
add_action( 'init', 'register_shortcodes');

2) But I can also create the whole shortcode without that function (register_shortcodes):

function four_columns() {
	my code here
}
add_shortcode('knowledgebase', 'four_columns');

In which cases you should use option 1 in stead of option 2?

Guido

Chris Whiteley on "Query Custom Post Type By Category and Author"

$
0
0

I am trying to query a custom post type, and I need it to show posts from both a single category and a single author. I thought I would have to use WP_Meta_Query but I cannot seem to figure out how to get things working.

Can anyone perhaps share how I would create this type of query?

knoppys on "update_post_meta() and wp_mail() when adding a new psot"

$
0
0

Hi All

I have a custom post type ('booking')that uses around 20 custom fields to populate the post content. Once this content is added, various calculations are made, various other fields are automatically populated and everything ends up as a 'booking'.

So heres the problem, when the post is published, Im hooking into 'updated_post_meta' to send an email using wp_mail() containing all the posts content and meta.

However, the mail is being sent before the meta fields are being added to the database? I need a way to add the data, save it and then send the mail.

Thanks


Arevico on "Modifying Main Query Single Page Request"

$
0
0

Hi al,,

I've a question regarding implementing the following functionality. If a specific page is requested, i want to switch the content based on some option set in the admin screen.

My main idea was to use pre_get_posts to change this behaviour. However,the documentatation explicitly lists: 'pre_get_posts should not be used to alter the query for single Page requests'. Now, my main question is: which hook should I use to override the WP_Query object pointing to the new page?

FreddyAZ on "Fixed value (readonly) in a custom field in the comment area"

$
0
0

Hi there,
I was wondering if it is possible to add with javascript an unchangeable value ("comments") to a custom field in the WordPress comment area.
In this moment I have this situation:
IMAGE

I would like the field N.3 to be readonly and have a default value attribute that can not be modified.

The id of the third field is #textar.

Any idea? Thank you in advance.

Banshee01 on "how can add jquery code in metabox?"

$
0
0

hey can i add my following code into the metabox?

<html>
    <head>
        <title>You Have To Have a Title</title>
    </head>
    <body>
        <form method="post" autocomplete="on" action="process_form.php">
                search: <input type="text" name="gname" >
                </br>  </br>
                ID:  <input type="text" name="idgame">
                <input type="submit" name="submit" value="Submit">
        </form>

        <div id="MyResultsDiv"> Your results will display here.</div>

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script>

        <script>
        $('form').submit(function (e) {

            e.preventDefault();

            var gnameInput = this.children["gname"].value; // the "gname" input

            var idgameInput = this.children["idgame"].value;// the "idgame" input

            var postVariables = {
                gname: gnameInput,
                idgame: idgameInput
            };

            var postUrl = this.action; // the "action" attribute of your form.

            $.post(postUrl, postVariables, function (result) {

                $("#MyResultsDiv").html(result);

            }).fail(function (result) {
                console.log("Wean Error!");
            });
        });
        </script>
    </body>
</html>

Ashley Michèlle on "Display only manual excerpt on index (function)."

$
0
0

This is my current functions.php custom function:

function custom_excerpt($text) {  // custom 'read more' link
   if (strpos($text, '[...]')) {
      $excerpt = strip_tags(str_replace('[...]', '<div class="readmore"><a class="readmore" href="'. get_permalink( get_the_ID() ) . '"><small>CONTINUE READING</small></a></div>', $text), "<a>");
   } else {
      $excerpt = '' . strip_tags($text) . '<div class="readmore"><a class="readmore" href="'. get_permalink( get_the_ID() ) . '"><small>CONTINUE READING</small></a></div>';
   }
   return $excerpt;
}
add_filter('the_excerpt', 'custom_excerpt');

You can see it in action here: http://ohmybonbon.com.

I would like to see only the manual excerpts displayed, and if there is no manual excerpt, I would like it to only display the 'continue reading' link, rather than an automatic excerpt (as it is currently doing).

I'm sure this is probably incredibly easy, but my brain isn't working. So, of course, help is greatly appreciated!

agsharad07 on "Trying to get property of non-object in WP_Query"

$
0
0

I am creating a sample portfolio showcase template. In that i have created categories like products,services,etc. Now i have created a page to display each kind of post of each category. Like a page for product category,one for service.....
I have kept the slug name of category-page pair same i.e. Product category and product page have same slug. SO that i may fetch the slug of current page and display all posts of it from that named category.

But whether i use WP_Query or $wpdb both fails giving following error:

Notice: Undefined offset: 1 in E:\xampp\htdocs\wp-test\wp-includes\query.php on line 3680

Notice: Trying to get property of non-object in E:\xampp\htdocs\wp-test\wp-includes\query.php on line 4553

Notice: Trying to get property of non-object in E:\xampp\htdocs\wp-test\wp-includes\query.php on line 4555

Notice: Trying to get property of non-object in E:\xampp\htdocs\wp-test\wp-includes\query.php on line 4557

Also that the content i had written at the time of page creation is visible, but none of the posts.... why ??

My Code:

Note: that code i used for wpdb is commented.

<?php
//Template Name: my theme
get_header();
?>
<div id="maincon" class="container">
 <div id="content-con" class="content">

	<?php
	if(have_posts()): while(have_posts() ): the_post() ;
   ?><div class="row">
	<h1 id="mainhead" class="text-center"><?php the_title();
	endwhile;
	endif;?></h1>	  </div>

	<div class="row"><div class="col-md-offset-1 col-md-10">
 	<?php
	 global $post;
	$slug = get_post( $post )->post_name;
     // global $wpdb;
	 // $qu="select <code>post_title</code>,<code>post_content</code> from <code>wp_posts</code> inner join <code>wp_term_relationships</code> on <code>wp_term_relationships</code>.object_id=ID inner join <code>wp_terms</code>on <code>wp_terms</code>.term_id=<code>wp_term_relationships</code>.term_taxonomy_id where slug='".$slug."'";
	 // $res=$wpdb->query($qu);

	$args=array('post_type'=>'post',
				// 'name'=>$slug
				'tax-query'=>array('taxonomy'=>'category',
									'field'=>'slug',
									'terms'=>$slug
									)
				);
	//$args=array('name'=>$slug,'post_type'=>'post');
			$query=new WP_Query($args);
			if($query->have_posts()):while($query->have_posts()): the_post();

	// if(!empty($res)){
	?>
	<h2 class="text-center" id="article-head"><?php the_title();//  echo $res[0]->post_title;?></h2>
	<p><?php the_content();//the_excerpt();echo $res[0]->post_content; ?></p>

	<?php
	// }
		// else{
			// echo "sory";}
		  endwhile;wp_reset_postdata();endif; ?>
		</div>
	</div>
 </div>

</div>

<?php get_footer(); ?>

pangalanrao on "do_action in header works for regular post but not for custom post type"

$
0
0

I am using customizr theme. For all regular posts and pages the header part (get_header) loads properly. I have a custom post_type as assignments which is created through a plugin. While loading those post type the header doesn't load at all. I debugged myself and found that header.php has several do_action which are not working in case of custom post type. The plugin has separate template for post_type and in that get_header(); is mentioned. This issue is only related to customizr theme while in other themes everything works fine. Other than changing the theme is there any solution?

Guido on "Custom Product Fields"

$
0
0

Hi,

I have added some custom product fields to the productpage of woocommerce but I am wondering if I did it the right way or not:

woocommerce_wp_text_input( array( 'id' => 'author', 'class' => '', 'label' => __('Author') ) );
woocommerce_wp_text_input( array( 'id' => 'publisher', 'class' => '', 'label' => __('Publisher') ) );

The website is up and running, but today I noticed the id other fields start with '_'.
So '_author' and '_publisher'. Does it matter?

Guido


Scott Paterson on "Global $pagenow not available in multisite"

$
0
0

Here is my code. Works fine on non-mulitsite, but on multisite, the globals $pagenow and $typenow are empty.

Any ideas why or how to fix this?

global $pagenow, $typenow;

if ( in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) && $typenow != 'download' ) {
...

Thanks,
Scott

Guido on "Add custom fields to product search"

$
0
0

Hi,

I'm using this tutorial to add my custom fields to the Woocommerce product search function (see: Search Woocommerce Products by custom fields example).

Woocommerce search is the same as normal WP search, but only searches in post type 'product'.

This script works great local and on my own (Linux) server, but on another server the search results are zero.. always. When removing this script, Woocommerce search works again.

Only thing I can think of is a conflict on certain types of servers and the SQL variables like:
AND CAST / INNER JOIN / AS CHAR / LIKE

Is this possible?

Guido

WPnewb2014 on "Small change in theme structure"

$
0
0

I have a theme that is custom coded, I dont want to change to much, if you go to my page you will see about halfway down (under slideshow) there is an "about" block, i just want to remove that

I know its in the sites php files, but as usual they are a maze to sort through

Anyone?

a42 on "add_filter hack is not working..."

$
0
0

Hi there

I'm trying to hack a plugin by insert a dynamic variable into a wp_mail()...

The plugin initialize a send_to - variable with:

$this->send_to = get_option( 'woocommerce_product_enquiry_send_to' );

this is being used as follow:

if ( wp_mail( apply_filters( 'product_enquiry_send_to', $this->send_to, $product_id ), $subject, $message, $headers ) )
echo 'SUCCESS';
else
echo 'Error';

I have created a function:

function enquiry_to_vendor($email , $product_id ) {
global $product;

$vendors = get_product_vendors( $product->id );
if( $vendors ) {
foreach( $vendors as $vendor ) {
$email = $vendor->paypal_email;
}

return $email;
}

}

and applying add_filter:

add_filter( 'product_enquiry_send_to', 'enquiry_to_vendor', 11, 2 );

But I get nothing in the send_to field in the wp_mail() when do that add_filter - I have also tried to remove_filter() but with out luck...

Has this to be done in another way since WP ver. 4.1.1 or am I missing something ?

Cheers,
Adam

BernhardPunz on "Bulk insert posts is really slow and skips entries"

$
0
0

Hi,

I'm writing a plugin to parse a bunch of XML files with the NewsML standard and insert them into the database as custom post type. Everything works fine and as intended, but especially at the first activation of the plugin, there are many files to import and this takes a long time. I'm talking about up to 2000 files.

The parsing process takes about 20 seconds which is ok for me but the whole import process takes up to 6 minutes or more and I don't think that it is the best practice to raise the execution time limit.

Sometimes my script just skips all files after the execution time limit and shows a blank page, in my last try I got an php error and sometimes it just works. (I assume it works when it does not reach the time limit).

Here is my code to import the array of entries in the database. Since I began developing wordpress plugins just 6 weeks ago I know that it's not the best code you've ever seen.
The insert from the list to the database.

So I'm looking for a solution with 2 goals:
1: Don't skip any files. I don't know how to bypass the execution time limit. (Maybe split the array and import the single parts?)
2: Speed the process up. The 20 seconds for the parsing is okay, but the insert takes way to long in my opinion.

I would be happy for any advice and tips.

Viewing all 8245 articles
Browse latest View live




Latest Images