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

Alex Kozack on "How do I change the number of posts indicators"

$
0
0

Hello. I use this hack

add_filter( 'parse_query', 'my_pagetemplate_filter' );
function my_pagetemplate_filter( $query ) {
	if(!current_user_can('edit_others_posts')){
		global $current_user;
		set_query_var( 'author',$current_user->id );
	}
}

It displays only their authors write, but figures remain the same number of posts. Screenshot


danishsameer on "Need Fwd Text Button"

$
0
0

Hello Everyone

i need little help..i want to insert a button in every post automitcally when any user click that button the text of that post automatcally go to the text area of form which i m using in my site u can see button in sms4smile site

in the last of everypost there is a button named send/forward this sms to anyone in pakistan when you clcick that button the text automtically go to textbox please check n if anyone knows about that please tell me

thanks,

Regards,
Danish

shekinah_studios on "Create plugin to parse csv and autocreate pages using wp_insert_post()"

$
0
0

I am proficient enough with php and wordpress to get by so long as I have a starting point, but I generally find it difficult to find that starting point on my own, so I am reaching out for some suggestions on the problem I am trying to solve here.

Here is the main business objective: I am working with a small school photography studio and am trying to build something on their site to better handle class group photo naming. So basically, the photographers go and take pictures of each of the classes at all of the client schools. Some schools have 14 classes some have 30+. Once the photos are taking, we select the best one and photoshop if necessary and then (currently) we print them out and send them back on a form where the teachers have to then list the kids names in each of the rows. They then have to send them back.

OK, so I am trying to translate this into WP to make it much faster. The actual form and page with the image is of course easy to create with a template. The problem that I am having is that I want a way to not have to add each teacher page manually. That would take loads of time.

Therefore, I want to utilize a plugin that I write that will allow a user to upload some data, choose a few options, and the pages will then be created using wp_insert_post().

Here is the general process I want to follow:

Pictures are uploaded separately and are already in gallery with a specific file name.
At this point in time, there are no associated posts, but there is a template that essentially holds a placeholder at the top that will pull in a picture based on teachers last name, then the form at the bottom.

A plugin will be available from the admin menu that will offer a way to use wp_insert_post to create the pages automatically for all teachers and all schools, it should look like the following:

A drop down menu that holds all the school names that are available (this should be populated with all of our schools at some point).
Best case scenario, user should be able to upload a csv file that contains the teachers name, the image name (so can be linked from the gallery on the template page), the password for each teacher.

Once the csv file is uploaded, user will be presented with a table to verify all info is correct, if so, a submit will create all the teacher pages.

Thanks in advance for the help...I am at an impasse right now in trying to figure out where to start this thing.

Mike

odp123 on "pdf upload on user profile page"

$
0
0

Hey folks,

I am writing a rather extensive alteration of the user profile page. Among the alterations I need users to be able to upload a pdf file.

What I need help with is how to actually handle the pdf file, so it gets uploaded preferable with username_ prepended to filename (bob_specs.pdf)

What I have so far:

///////////// PDF upload //////////////////

add_action( 'show_user_profile', 'pdf_upload' );
add_action( 'edit_user_profile', 'pdf_upload' );

function pdf_upload( $user ) { ?>

<table class="form-table">
<h3>Upload PDF specifications</h3>
<span>tutorial</span>
<tr>
<th><label for="pdf">PDF</label></th>

<td>
<input type="file" name="pdf" id="pdf" value="<?php echo esc_attr( get_the_author_meta( 'pdf', $user->ID ) ); ?>" class="regular-text" /><input type='button' class="upl button-primary" value="Upload PDF" id="uploadpdf"/><br />
<span class="description">Please choose a PDF file to upload</span>
</td>
</tr>

</table>
<?php }

///////////// PDF upload END //////////////////

This only adds the upload form to the profile page. So I am missing the actual handling of the file.

after successful upload I call this in my author.php file

<?php $user = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); ?>
....
<?php echo $user->pdf; ?>
....

Any inputs, advice, or code examples would be greatly appreciated.

PS. not looking for plugins

Pete on "How do I make my custom taxonomy base/permalink words separated by a hyphen?"

Pete on "How do I make my custom taxonomy base/permalink words separated by a hyphen"

jeremyschultz on "Merging post wp_queries with array_merge not working"

$
0
0

I'm attempting to get a set of posts with a wp_query, and if it returns less than two I make a second wp_query and merge the results. In my test case, I get one result on query #1 and two on query #2 but in all cases the combined query #3 is empty.

<?php $query = new wp_query( array ( 'posts_per_page' => '2', 'orderby' => 'date', 'category_name' => 'as,ac,ai', 'cat' => '96,-31,-98', 'post__not_in' => array(718) ) );
if (($query -> post_count) < 2) {
	$query2 = new wp_query( array ( 'posts_per_page' => '2', 'orderby' => 'date', 'category_name' => 'as,ac,ai', 'cat' => '-96,-31,-98', 'post__not_in' => array(718) ) );
	//echo $query -> post_count; returns 1
	//echo $query2 -> post_count; returns 2
	$query3 = array_merge($query, $query2);
	//echo "query3 post count is " . $query3 -> post_count; returns blank
	//print_r($query3); nothing
}

I've tried everything I can think of and nothing returns anything. What am I missing?

sblomberg on "Feature Pointer Alternatives"

$
0
0

According to this ticket comment by a WordPress dev, the WordPress core "feature pointers are designed only for internal pointers."

I would like to know if the WordPress team or other devs have alternative recommendations for alerting WordPress users of new plugin features. Thanks!


llidanlq on "User enumeration?"

$
0
0

Hi everyone,

I'm sure this has been spotted already but in 3.8.1 there appears to be a user enumeration fault in the password reset feature of the admin portal. I haven't seen the backend as I'm only pentesting a site for someone (quite possibly there exists an option to change or modify that feature - I dunno) but it seems odd that it would be there regardless.
Type any username and password, hit the reset feature, enter a valid username and it tells you the email has been sent. Enter an invalid username and it tells you the username is invalid.

I searched and couldn't find any info on it. I don't mind if it's not fixed. I just thought I'd sign up and tell someone about it.

Good day

abdulkza250 on "How to add a placeholder to (wp_editor) TinyMce ?"

$
0
0

I would like to know how to add a placeholder (wp_editor) TinyMce. Any help would be appreciated.

hawkman4188 on "Match form input with custom fields on custom post type"

$
0
0

I am trying to build some functionality for a client who wants their clients to be able to check the repair status of their item. I have setup a custom post type called "clients" to store the clients in. I have also created custom fields in the post type "clients" such as "first name", "last name", "order number", and "repair status".

What I need to do is create a form where the customer can put in their name and their order number and it will show the status of their repair.

I know the basic idea is to match the input info with the values of the custom fields, but I don't know how to match those input values and pull and show the "repair status" value.

Any code samples you can throw my way would be much appreciated!

greenpixi on "Virus In WordPress In .Zip Version is 3.8.1"

$
0
0

I downloaded Version is 3.8.1 and installed successfully. But when i try to visit mywebsite.com/wp-admin my security app(K9 Web Protection) block this site. then i scanned the WordPress Zip File Version is 3.8.1 in http://www.virustotal.com it detects 2 virus in this zip file!!! What is this??
Expecting Your Opinion.

Thanks,
Polash Khan

lookitschloe on "How to add anchor tag at the top of posts, past the header and nav bar?"

$
0
0

Hi, my site is here: http://wedding.chloe-nguyen.com/

I am using the default Twenty Fourteen theme, modifying in a child theme (my first).

Scroll down and click one of the featured posts. You get taken to the single post page at the top of the page. I would like it to scroll down past the castle, past the nav bar, to the top of the title of the post. I would like my readers to get to the content while keeping the full-screen announcement on every page. I'll add a secondary nav in the right sidebar via a widget.

I found this: http://wordpress.org/support/topic/automatically-scroll-down-to-content?replies=6 but I don't know JS and the OP's site is no longer a header followed by the post(s).

On my site, the div that holds the content is:
<div id="main" class="site-main">
(I did not change this; it is the default code in the Twenty Fourteen theme)

Therefore, I think the answer is to make the links that go to posts have #main at the end, but I don't know how.

Here's the featured-content.php code:

<?php
/**
 * The template for displaying featured content
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */
?>

<div id="featured-content" class="featured-content">
	<div class="featured-content-inner">
	<?php
		/**
		 * Fires before the Twenty Fourteen featured content.
		 *
		 * @since Twenty Fourteen 1.0
		 */
		do_action( 'twentyfourteen_featured_posts_before' );

		$featured_posts = twentyfourteen_get_featured_posts();
		foreach ( (array) $featured_posts as $order => $post ) :
			setup_postdata( $post );

			 // Include the featured content template.
			get_template_part( 'content', 'featured-post' );
		endforeach;

		/**
		 * Fires after the Twenty Fourteen featured content.
		 *
		 * @since Twenty Fourteen 1.0
		 */
		do_action( 'twentyfourteen_featured_posts_after' );

		wp_reset_postdata();
	?>
	</div><!-- .featured-content-inner -->
</div><!-- #featured-content .featured-content -->

Of course, this doesn't include the next post / previous post links, links to posts from the calendar, etc. I just thought I would start with the ft posts. How do I say, "on every post link, add #main at the end"? Am I looking in the wrong place?

Thank you in advance.

Sincerely,
Chloe

PS: If you are curious, I want to get baller enough to do something like this: http://johngeorge.com/site/ -- you see how the nav bar gets short as you scroll? I want to do that, but instead of the nav bar, the announcement. But I still need to be able to know how to add the anchor link so when you click on a link that goes to a post, it goes to a page with the shortened announcement and post content.

achsanos on "A comment box for index page (the page, no the posts inside the loop)"

$
0
0

I want to place a custom comment box on index.php, and I did it inserting a call to the comments_template:

$withcomments = 1;
comments_template();

However, the comment box is getting the id of the last post called in the loop, redirecting to it page after done a comment. I need a comment box for the index.php, not for posts (and no redirections). Is there something wrong?

msdb88 on "Press This for custom post types"

$
0
0

Hi,
I've looked hi and low for a "press this" plugin or code that can add information like links and text to a custom post type. The two most promising results have been:
1) http://wordpress.mfields.org/2010/bookmark-this/
2) Press This Custom Post Types

1) the first code logs me off of my site, I'm guessing for some security reason...
2) the second written by the almighty scribu :) seems to be outdated. That code only works if i change:

$link = str_replace('post-new.php', "post-new.php?post_type=$post_type", $link);

to

$link = str_replace('press-this.php', "post-new.php?post_type=$post_type", $link);

which bypasses all of the press this functionality completely.

Is there anyone who has figured this out, or knows why this is such a limited feature?
...Thanks!


jerryskate on "Let visitors filter pages, possible?"

$
0
0

Hi!

I have an aggregator site, that display a feed of youtubevideos. On the front, it displays all feeds from all the pages mixed up, and I have a sidemen, with different pages with one feed on. I wonder if it would be possible to let user filter the pages so it mixes the different feeds from the pages at their choose. Or maybe filer ut feeds from keywords on the frontage?

Site: http://www.skatevids.me

jepper on "custom_pre_get_posts query modification gives 404"

$
0
0

Hi

I've got a nasty problem that i can't seem to get rid of.

In an attempt to remove slugs for a custom post type I've followed this guide:

http://ryansechrest.com/2013/04/remove-post-type-slug-in-custom-post-type-url-and-move-subpages-to-website-root-in-wordpress

We got this working but with updates it somehow broke. Now the WP_Query modifications result in a 404 error page, while the post exists!

So this is my function, with debug code:

function custom_pre_get_posts($query) {
    global $wpdb;

    if(!$query->is_main_query()) {
        return;
    }

    //echo '$query before: <pre>' . print_r($query, true) . '</pre>';

    $post_name = $query->get('category_name');
    //$post_name = $query->get('name');
    $post_name = str_replace(".html", "", $post_name);

    $post_id = $wpdb->get_var( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_name = %s LIMIT 1', $post_name ) ); 

    //echo '$post_name: <pre>' . $post_name . '</pre>';

    $post_type = $wpdb->get_var(
        $wpdb->prepare(
            'SELECT post_type FROM ' . $wpdb->posts . ' WHERE post_name = %s LIMIT 1',
            $post_name
        )
    );

   // echo '$post_type: <pre>' . $post_type . '</pre>';

    switch($post_type) {
        case 'product':
            $query->set('product', $post_name);
            //$query->set('name', $post_name);
            //$query->set('p', $post_id);
            //$query->set('page_id', $post_id);
            $query->set('post_type', $post_type);
            $query->is_single = true;
            $query->is_page = false;
            break;
    }

   echo '$query after: <pre>' . print_r($query, true) . '</pre>';

    return $query;
}

which results in a 404 with this query after:

WP_Query Object
(
    [query_vars] => Array
        (
            [category_name] => m-double-you-sachet-whey-isolate.html
            [error] =>
            [m] =>
            [p] => 0
            [post_parent] =>
            [subpost] =>
            [subpost_id] =>
            [attachment] =>
            [attachment_id] => 0
            [name] =>
            [static] =>
            [pagename] =>
            [page_id] => 21037
            [second] =>
            [minute] =>
            [hour] =>
            [day] => 0
            [monthnum] => 0
            [year] => 0
            [w] => 0
            [tag] =>
            [cat] =>
            [tag_id] =>
            [author] =>
            [author_name] =>
            [feed] =>
            [tb] =>
            [paged] => 0
            [comments_popup] =>
            [meta_key] =>
            [meta_value] =>
            [preview] =>
            [s] =>
            [sentence] =>
            [fields] =>
            [menu_order] =>
...
            [product] => m-double-you-sachet-whey-isolate
            [post_type] => product
        )
...
    [is_admin] =>
    [is_attachment] =>
    [is_singular] =>
    [is_robots] =>
    [is_posts_page] =>
    [is_post_type_archive] =>
    [query_vars_hash] => 60f1fdf5aebc76aba270391b0658101c
    [query_vars_changed] =>
    [thumbnails_cached] =>
    [stopwords:WP_Query:private] =>
    [query] => Array
        (
            [category_name] => m-double-you-sachet-whey-isolate.html
        )

)

I've removed some for brevity. Trying to load a post id with a valid ID does not work as well.

How do i go from here?
How do i debug it?

The post is valid and under the id as found by the function

Thanks!

Da9L on "Single WordPress Core - Multiple sites"

$
0
0

Hello

Here at my work, we host multiple Wordpress sites. To conserver space, we were thinking about the possibility to use a single wordpress core, on all those sites. Also needed is multiple admin access for each site.

Can anyone of you guys in here tell me how big of a deal this would be to make? Without any background knowledge of the subject, i believe it is going to be a pretty big task.

But maybe there even exists a plugin for this kind of task?

~D

servicebyte on "Get Plugin Url For Android App"

$
0
0

We are in the process of building a Wordpress Plugin and accompanying Android App. The Android App requires a url to retrieve the POST data from the Plugin, but I cannot figure out the absolute url for the plugin. I thought it should be website.com/wp-content/plugins/plugin.php, but this returns nothing.

Please instruct.

bkbarton on "Adding custom input and linking to page sidebar"

$
0
0

I must be missing something...

Is there a way to...

  • have a page template
  • that has a 'custom' text input area in admin
  • that then passes this 'custom' text to the associated page sidebar
  • ...meaning, this 'custom' text will not be visible anywhere else, but the specific associated page it was meant to accompany

In my research, I have ways of adding custom meta data or links or images or to the sidebar of a page... but no way of adding associated content that matches that of the main post. The WordPress community has to have come up with someway of including this content. It is a content management system, right?

Please show me what I'm missing...

Thanks.

Viewing all 8245 articles
Browse latest View live




Latest Images