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

A31 on "Insert PDF File to Custom Database Table"

$
0
0

Hi all,

Can anyone please advise me how I can insert a PDF file that a user selects from a html form into a custom table in the database?

My code so far is:
$OrderNumber= $_POST['txt_OrderNumber'];
$UploadAttachment = $_POST['txt_Attachment'];

$wpdb->insert('wp_Attachments',
array(
'OrderNumber' => $NextOrderNumber,
'FileContent' => $UploadAttachment
),
array(
'%s',
'%s'
)
);

Although I do not get any errors, the size returned in the database is 0.

Any advice please?


jjkiesch on "shortcode to add content to other parts of the page"

$
0
0

i created a shortcode for my site that allows them to have content show up in a lightbox. when the html for the lightbox content gets rendered, it is displayed inside of the parent tag that holds the shortcode.

is there a way i can write my shortcode function to somehow hook into wp_footer and add dynamic content to it? having the lightbox content inside of the parent html tag is causing rendering issues sometimes.

kia_williams on "From 'custom post type' ... to post submission form?!?!?!?"

$
0
0

I have "post from site", give a nice box in a widget with text area for title -and- blog post.. all well.

except, I have no use on my site for front-end -blog- posting, at least in terms of. "text area for title -and- blog post"

what i do have is SIX -WEEKS- i kid you not of TRYING to find the step from 'custom post type'..

Custom Post Types

Custom post types are new post types you can create. A custom post type can be added to WordPress via the register_post_type() function. This function allows you to define a new post type by its labels, supported features, availability and other specifics.

Note that you must call register_post_type() before the admin_menu and after the after_setup_theme action hooks. A good hook to use is the init hook.

Here's a basic example of adding a custom post type:
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'acme_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'public' => true,
'has_archive' => true,
)
);
}

This creates a post type named Product identified as acme_product. The register_post_type() function receives two major arguments. The first one is labels which define the name of the post type in both plural and singular forms. The second one is public which is a predefined flag to show the post type on the administration screens and to make it show up in the site content itself, if it's queried for.

There are many more arguments you can pass to the register_post_type() function, to do things like set up hierarchy (to behave like pages), show the new post type in searches, change the URLs of the new posts, and hide or show meta boxes in the post edit screen. These parameters are optional, and you can use them to configure your post type on a detailed level.

a custom post type (as i have had hammered again and again and again from numerous tutorials.. relates to Post types, which are nav menu, pages, posts.........

...

.
.
.
..

.
.
.
.
..

<html>
<form name="input" action="html_form_action.asp" method="post">
 Video Embed code: <input type="text" name="vidembed">
 <input type="post" value="post">
 </form>
</html>

this is it, this is all i want to do.. one TEXT ENTRY LINE and a 'post' button.... but there's no tutorial i can find that explains how to customise the default fields for a custom post type or add any........

Custom post types are new post types you can create. A custom post type can be added to WordPress via the register_post_type() function. This function allows you to define a new post type by its labels, supported features, availability and other specifics.

..... functions.php? .. single.php?

As you can tell im EXTREMELY FRUSTATED, with the documentation or advice for what in html and php can be twenty five lines over TWO files.

please please puhlease, put me out of my misery.

Devtard on "Some allowed_tags can't be changed"

$
0
0

This code removes almost all allowed_tags in comments:

define('CUSTOM_TAGS', true);
global $allowedtags;

$allowedtags = array(

);

This is what is displayed under the comment form (regardless of the theme I use):

You may use these HTML tags and attributes: <pre class="" title="" data-url=""> <span class="" title="" data-url=""> <code class="" title="" data-url="">

Any idea how to disable these tags?

crempel on "My plugin breaks Post Preview"

$
0
0

I'm having a problem with a plugin that I've been developing. The problem is that the plugin breaks the ability to preview a post, whether it's in draft or published. It simply brings up Wordpress's 404 page. I haven't been able to track down the problem, so I'm coming to you to ask for ideas - possibilities that could cause this behaviour. I'm not going to post any code here, the plugin spans many files and is several thousand lines of code long, so I'll give a brief description of the kinds of things the plugin does.

Firstly, it creates some new Post Types. Secondly, it sets up some rewrite rules (using add_rewrite_rule) and adds a few query vars (they are all prefixed and unique). Thirdly, it hijacks the request and sets up some data IFF one of those query vars is set. Finally, it hijacks the template selection process to inject posts of certain post types in custom templates.

I've ensured my Post Types are publicly_queryable, however, the problem also affects regular Posts (non-custom post-types). I've tried to go through and isolate what might be causing the problem, but I can't find anything.

Here is one piece of code that I have been looking at a little more closely than others:

if(is_preview())
    {
        $query->set('post_type', get_post_types(false,'names') );
    }
    else if (is_home() && $query->is_main_query())
    {
        $query->set('post_type', array("post", "review", "article", "interview", "preview", "news"));
    }
    return $query;

I read somewhere, something, about setting the post_type query var this way if it's a preview, but it's had no effect.

So, any ideas? Thanks alot!

Devtard on "How to print a message after submitting a comment?"

$
0
0

Hello. I want to print a message after submitting a new comment. Any idea how to do that? (I've tried using comment_post, but it doesn't let me print anything.)

brometheus55 on "Help with WordPress Permalink 301 Redirect via .htaccess"

$
0
0

I am currently attempting to change the permastructure of all of my WordPress posts from:
/%year%/%monthnum%/%postname%/
to just
/%postname%/.

I have already made the change in WordPress and added the following code to my htaccess file to initiate the 301 redirects:

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.+)$ http://www.mydomain.com/$3

Now everything is working perfectly except for 1 thing. It has caused all archived date pages, for example http://www.mydomain.com/2013/8/20, to redirect to http://www.mydomain.com/20, which causes 404s.

My question is how do I edit the code to not reflect those archived dates. I imagine it's something fairly simple but i know minimal coding and have already spent hours searching online only to come up short. I'm very surprised as the code I used was given as a common fix. I assume most people didn't either use their calendar widgets, or never noticed this problem who used this method.

Anyway please and thanks for help.

kikimarie123 on "Next/Previous Posts Link with Custom Post Type"

$
0
0

I'm using custom post type to query all the posts from post type: 'news-articles' and under a specific meta value. I've tried everything to get some next/previous links to appear and nothing is working.

Here is my code:

<div id="news-articles">
<?php
$args = array(
	'numberposts' => -1,
	'posts_per_page'  => 5,
	'post_type' => 'news-articles',
	'meta_key' => 'release_type',
	'meta_value' => 'In the News'
);

$the_query = new WP_Query( $args ); ?>

<?php if( $the_query->have_posts() ): ?>

	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

		<div class="news-article" id="in-the-news">

		<div class="investment-image">

		<?php $associations = get_field('associations');
		if( $associations ): ?>

		<?php foreach( $associations as $association): ?>
			<?php
			$photo = get_field('investment_logo', $association->ID); ?>

			<a href="<?php the_permalink() ?>" title="<?php printf(__('%s','rys'), get_the_title()) ?>" rel="bookmark">
			<img src="<?php echo $photo['url']; ?>" alt="<?php echo $photo['alt']; ?>" />
			</a>

		<?php endforeach; ?>

		<?php endif; ?>

		</div><!-- .investment-image -->

		<div class="news-info">

		<strong><a href="<?php the_permalink() ?>" title="<?php printf(__('%s','rys'), get_the_title()) ?>" rel="bookmark" >
		<?php the_title(); ?></a></strong><br>

		<em><?php the_field('publication_source'); ?></em><br>

		<span><?php echo get_the_date(); ?></span><br>

		<a href="<?php the_permalink() ?>" title="<?php printf(__('%s','rys'), get_the_title()) ?>" rel="bookmark" class="more">more</a>

		</div><!-- end .new-info -->

		</div><!-- end .new-article -->

	<?php endwhile; ?>

<?php endif; ?>

<?php wp_reset_query();  // Restore global post data stomped by the_post(). ?>
</div><!-- end #news-articles -->

<?php americsecur_entry_bottom(); ?>
</div><!-- end of #post-<?php the_ID(); ?> -->

        <?php
		endwhile; 

		get_template_part( 'loop-nav' ); 

	else : 

		get_template_part( 'loop-no-posts' ); 

	endif;
	?>     

<?php wp_link_pages('before=<p>&after=</p>&next_or_number=number&pagelink=page %'); ?>

</div><!-- end of #content-section -->

<?php get_footer(); ?>

Nothing is working. I've tried multiple different code snippets and still nothing. Please help!


dubzzdigital on "Adding a second button with php code?"

$
0
0

Hi all,

I have the website Cottage Flair and I am wanting to add a second button next to the "Shop Now" one in the purple bar of the homepage. I have tried editing the php functions myself but can't for the life of me figure it out. If anyone could please help it would be much appreciated! Cheers!

This is what I am looking at:

/****************************************************************************************/

if ( ! function_exists( 'attitude_home_slogan' ) ) :
/**
* Display Home Slogan.
*
* Function that enable/disable the home slogan1 and home slogan2.
*/
function attitude_home_slogan() {
global $attitude_theme_options_settings;
$options = $attitude_theme_options_settings;

$attitude_home_slogan = '';
if( ( !$attitude_home_slogan = get_transient( 'attitude_home_slogan' ) ) && ( !empty( $options[ 'home_slogan1' ] ) || !empty( $options[ 'home_slogan2' ] ) ) ) {

if ( "0" == $options[ 'disable_slogan' ] ) {
$attitude_home_slogan .= '<section class="slogan-wrap clearfix"><div class="container"><div class="slogan">';
if ( !empty( $options[ 'home_slogan1' ] ) ) {
$attitude_home_slogan .= esc_html( $options[ 'home_slogan1' ] );
}
if ( !empty( $options[ 'home_slogan2' ] ) ) {
$attitude_home_slogan .= '<span>'.esc_html( $options[ 'home_slogan2' ] ).'</span>';
}
$attitude_home_slogan .= '</div><!-- .slogan -->';
if ( !empty( $options[ 'button_text' ] ) && !empty( $options[ 'redirect_button_link' ] ) ) {
$attitude_home_slogan .= ''.esc_html( $options[ 'button_text' ] ).'<!-- .view-work -->';
}
$attitude_home_slogan .= '</div><!-- .container --></section> <!-- .slogan-wrap -->';
}

set_transient( 'attitude_home_slogan', $attitude_home_slogan, 86940 );
}
echo $attitude_home_slogan;
}
endif;

/****************************************************************************************/

Claudio on "How to copy post into page"

$
0
0

I need to render a given post into a page using a shortcode. The page shall look exactly as the post (but must be a separate post/page).
In the shortcode function I was able to retrieve the post using get_post($post_id), but I don't know how to render the retrieved information.
How can I display the post with all the elements?
thanks!

zearth on "can I used slug instead of ID in add_rewrite_rule?"

$
0
0

question can I just used slug name instead of id for this kind of add_rewrite_rule

add_rewrite_rule('news/([^/]+)/?$','index.php?page_id=$matches[1]','top');

I'm not sure if what parameters for the slug in query, what I see on several samples are page_id only and I cannot find any information for slug.

thanks

Novalyyn on "Filter to post title only"

$
0
0

In the plugin I'm working I'm trying to filter a little piece into the titles of posts, but only when that post is being shown. I have a quick is_single() check to prevent it from showing up on other pages.

However, it's being added to all titles on the single post page, including titles in navigation and links to other posts. I was thinking that I might be able to make it show only for the post by telling it to work only while dealing with things in the loop, but I'm not sure how to go about doing that.

What I have presently is basically:

function display_string( $title ) {
  if ( ! is_single() ) {
    return $title;
  }

  $my_string = 'test value';
  return $my_string . $title;
}

add_filter( 'the_title', 'display_string' );

omegaredmedia on "How do you make checkbox create automatic tag?"

$
0
0

I am looking to have a checkbox on my form create an automatic tag to my custom post type. At the very bottom of my form I have a checkbox to make my listing featured I want it to create an automatic tag for that listing (EX: Featured Roping or Featured Clinic)

http://teamroper.com/submit-an-event/

I feel like this should be simple but Ive hit a mental block any help would be awesome

uwwedoogie on "Can somebody explain this hacked page to me?"

$
0
0

Please & thanks!

<section class="content-narrow">
	<div id="content">
		<header class="page-header">
			<? the_title(); ?>
		</header>
		<? $pages = get_pages(array('child_of'=>$post->ID, 'parent'=>$post->ID, 'sort_column' => 'menu_order', 'sort_order' => 'ASC')); ?>
		<ul class="nav-tabs clearfix">
			<? foreach ($pages as $page): ?>
				<li><a href="#<?=$page->post_name; ?>" data-toggle="tab"><?=$page->post_title; ?></a></li>
			<? endforeach; ?>
		</ul>
		<article class="tab-content">
			<?php foreach ($pages as $page): ?>
				<div class="tab-pane clearfix" id="<?=$page->post_name; ?>">
					<? if ($page->ID == 276):
						foreach (get_pages(array('child_of' => $page->ID , 'parent' => $page->ID, 'sort_column' => 'menu_order', 'sort_order' => 'ASC')) as $pageCh):
							echo
							'<div class="vcard" id="'. $pageCh->post_name .'">'.
								'<figure>'.
									get_the_post_thumbnail($pageCh->ID, 'full') .
									'<figcaption>
										<span class="fn n">'. get_the_title($pageCh->ID) . '</span>
										<small class="position">' . get_post_meta($pageCh->ID, 'occupation', true) . '</small>
										<i></i>
									</figcaption>' .
								'</figure>'.
							'</div>';
							$summary[$pageCh->post_name] = apply_filters('the_content', $pageCh->post_content);
							if (in_array($pageCh->ID, array(282, 315)) ) {
								foreach ($summary as $key=>$value)
									echo '<div class="summary summary-'. $key .'">'. $value .'</div>';
								unset($summary);
							}
						endforeach;
					else:
						echo apply_filters('the_content', $page->post_content);
					endif; ?>
				</div>
			<?php endforeach; ?>
		</article>
	</div>
</section>

vallsymachinant on "Show User Password ecrypt in MD5 - not in PHPASS"

$
0
0

Hello to you,

For the purpose of connecting to an external application to my site in wordpress, I need to get the word pass my users encoded MD5 and not PHPASS WordPress.

After various searches without results, I would like to know if any of you have already been able to recover a password in MD5 since WordPress is spent in PHPASS HASH?

The tracks I've found are:

http://stackoverflow.com/questions/4750 ... 5-password

http://wordpress.org/support/topic/plug ... ass-to-md5
http://stackoverflow.com/questions/1080 ... n-meta-val

After various tests, I finally get a result but the pass word does not match:

<?php
                    function encrypt_for_wordpress($plain_text_password) {
                        return md5("\$P\$B" . $plain_text_password);
                        }
                    $user_info = get_userdata(1);
                    // echo 'Username: ' . $user_info->user_login . "\n";
                    // echo 'User level: ' . $user_info->user_level . "\n";
                    // echo 'User ID: ' . $user_info->ID . "\n";
                    echo 'User P: ' . $user_info->user_pass . "\n";
                    $c2s_user_password = $user_info->user_pass;
                    $c2s_md5_user_password = encrypt_for_wordpress($c2s_user_password);
                    echo "md5 P : " . encrypt_for_wordpress($c2s_user_password). "\n";
                    $c2s_pass='testpassword'; echo(md5($c2s_pass));
                    echo ('</br> ------- </br>');

                ?>

Passwords encrypted pass obtained are:

phpass P: $ P $ Bv4iaLxehqIgbdpbXfjFgG/kcyBwqP /
md5 P: 7d8cd560a47f60fb32e66a71f50c26d9
  While the pass md5 should be
  5ced724eb662a20d198d04c0d90cba4d

Do you have any idea?

Thanks you very much !


paulf9 on "Slider Plug-In"

$
0
0

I am using the Zee-Noble Theme which uses a plug-in similar to the responsive slider. The slider only allows for two slider images to display. I have changed the php in the slider-settings.php so that on my dashboard or backend it shows that I can use up to four images in the slider. On the actual site only two images will show up in the slider. Do I need to add a new table somewhere in phpMysql for this to work or is this a problem with the JavaScript? Any help is greatly appreciated.

theleafszone on "integrate blueimp ajax chat with wordpress"

$
0
0

Has anybody integrated the blueimp ajax chat with wordpress (login to wordpress, automtically logged into chat). Seems like it should be fairly straight forward but not sure where to start

mirgcire on "How to find documentation on wp_remote_get arguments"

$
0
0

I have tried web searches and codex, but all I have learned is that it takes a second parameter $args, but no description of the options available. Specifically I am hoping to find an parameter that tells it to tolerate html errors.

Background:

I am porting a a wiki site (that I created) into wordpress. There are a lot of pages that I need to port so I created a metabox tool to help me do this. Basically, the tool is pulling the html from a wiki page and pushing it into a wordpress page. It works great on most of the pages, but on 2 of the pages, it encounters an error.

When it encounters the error, it just stops, no error message. But I am using the Chrome browser, so I opened the console window and found this error message. "Uncaught SyntaxError: Unexpected token <"

To investigate the error I used "view page source" on two pages, one that encounters the error and one that does not. I put both sources into an html editor to see if that would reveal the problem. Both pages have the same error.

So now I am hoping there is some way to have wp_remote_get tolerate the error.

danixland on "$wpdb->prepare uses single quotes instead of backticks"

$
0
0

Hello everybody,
I'm writing a couple functions that should go and read data from a custom table I've set in the database, right now I'm just using $wpdb->get_var and $wpdb->get_row, both with $wpdb->preare to sanitize my code, but WP is telling me that I have an error in my mysql code, here's a small example that is causing me trouble:

global $wpdb;
$table_name = $wpdb->prefix . "tdg_market";
$total_customers = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM %s", $table_name ) );

And here's what this code is returning:

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''wp_tdg_market'' at line 1]
SELECT COUNT(*) FROM 'wp_tdg_market'

As you can see the table name is between single quotes as reported from the WordPress error. So I've tried this line:
$total_customers = $wpdb->get_var( "SELECT COUNT(*) FROM wp_tdg_market" )
without using $wpdb->prepare and hard coding the name of the table, and it worked like a charm, so I came to the conclusion that is $wpdb->prepare's fault for using single quotes instead of backticks..

Is there a way to make $wpdb->prepare use backticks instead of single quotes??

Thanks a lot in advance

kitcorsa on "Direct Required - Flooring Site - E-commerce/booking"

$
0
0

Im looking for a bit of advice or direction here,

Im looking to make a site for my brother who is specialist flooring expert who can supply fit and repair floors. What i'm after doing is creating a restoration site for him which explains how he resorted and repairs old wood floors and preserves them. this part is straight forward enough etc, the wall i'm hitting and getting stuck on is an online quote / booking system which could have a payment (paypal option)

This service is fairly straight forward as my brother charges a set price per square meter, so what i'm trying to do is create a form where the customer can enter the width and length of there room, and get a quote, then send a booking email to my brother with the same information for my brother to contact them and arrange the appointment to go round, inspect and perform the job.

The next problem is what if the customer has more than one room?? is there a way of adding a room 2 room 3 etc etc etc if required.

We have also though about taking an online deposit via paypal for say 10%, we would not be able to take the full amount as the customer may enter the wrong size trying to get a cheaper job done, or over changed by not measuring correctly. Deposit first and final payment on completion would be better if possible.

Could anyone please point me in the right direction please. Thank you

Viewing all 8245 articles
Browse latest View live


Latest Images