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

hannamyluv on "Redisplaying $_POST data"

$
0
0

I have a form and it has checks in place that make sure that required fields are filled in. If the checks fail, the user is redirected to the original form. I use the $_POST data and re-fill in the completed parts of the form using URL parameters. The problem is that when the $_POST data is added to the redirect URL as a parameter, the spaces in the field are scrubbed.
e.g.
Form field 'question' is filled in with "this is a test" and processed as

$qtitle = $_POST['question'];

Check fails and the user is redirected like so
wp_redirect('http://www.example.com/submit-question/?err=2&qtl='.$qtitle);

The form then redisplays the form field 'question', pulling from the qtl parameter, as "thisisatest"

Why is it stripping the spaces and how can I fix it?


redhorizon0289 on "JS error UndefinedID in function preventing content loading"

$
0
0

Hello group, I have an issue with JS on specifically the contact us pages or Contact 7 form pages in our website. Using Firefox error console I can see an error on the page which I assume will keep the banners from dropping down, the widgets from loading, and contact form from sending emails. I am not a JS coder so would love some input from the group. The function is below. The specific call is: if (id.length == 0 && name.length != 0) {

http://gridone.us.com/contact-us

function InitMisc() {
  $j('#content input, #content textarea').each(function(index) {
    var id = $j(this).attr('id');
    var name = $j(this).attr('name');
    if (id.length == 0 && name.length != 0) {
      $j(this).attr('id', name);
    }
  });

  $j('#main label').inFieldLabels();

  $j('.rule span').click(function() {
	  $j.scrollTo(0, 1000, {axis:'y'});
	  return false;
 });
}

MiKeZZa on "When free shipping available don't show other options"

$
0
0

Is it possible to make (in Wordpress with WooCommerce) the shippingcost dropdown/radio button disappear when 1 of the options is 'Free shipping'?

This because of when people pay more than € 100 they get free shipping at my site and they than have the choice:
Free shipping
Paid shipping

This is ridiculous and I want to change that.

Is this possible?

Aureola on "How do you translate ( __('string') or _e('string') ) strings inside a function?"

$
0
0

Hi,
Surely I have made some typical newbie syntax error but I have tried just about everything. I would like to send off the words 'Read More' to the PO Editor for translation later; these words reside in this function:
(functions.php)

The original function for Read More - this one works but can't be translated:

function excerpt_ellipse($text) {  // custom 'read more' link
   return str_replace('[&hellip;]', '<a href="'.get_permalink().'">... READ MORE »</a>', $text); }
add_filter('the_excerpt', 'excerpt_ellipse');

This would be the internationalized function for Read More:

function excerpt_ellipse($text) {  // custom 'read more' link
   return str_replace('[&hellip;]', '<a href="'.get_permalink().'">... <strong><?php _e('</strong>READ MORE »',<strong>'ctequestrian') ?></strong> </a>', $text); }
add_filter('the_excerpt', 'excerpt_ellipse');

I have tried with and without the beginning/trailing <?php/?>, both with __( and _e( but I just can't get it to work. I have read about gettext in the Codex (http://codex.wordpress.org/I18n_for_WordPress_Developers) and several other tutorials but obviously I couldn't make use of them in this particular situation. In all other cases (simple strings of text in headlines and paragraphs) this _e( have worked fine.

Maybe someone here can help..?

TCBarrett on "Default custom post column to 'off' in screen options"

$
0
0

Is it possible to add a custom column to a post type with a default setting 'off' (unticked) in screen options?

nissimziv on "Bulk delete images while still using them as thumbnail (featured)"

$
0
0

I would like to delete all the images that were uploaded to posts and pages of a Wordpress site, while still using them as attachments/thumbnails (as featured images).
That’s why, I can’t bulk delete them from the media library, only from within posts and pages.
Since it’s a huge amount of images, I’d prefer using mysql command.
The string of the images is always written as follows - <img xxxx>, where xxx is varied based on the img location and other details such as alt, width and height etc.
The table is wp_posts and the fieldname is post_contnet
The closest command I came across to is –
UPDATE wp_posts SET post_content = REPLACE(post_content, '<img%>', '')
WHERE post_content LIKE '<img%>';
It doesn’t work.
Any clues?

kmurrayfrgraphics on "Javascript not functioning properly on wordpress"

$
0
0

A few weeks ago I added this javascript to my website and had it properly working on my website, but now it seems to not be functioning.

http://working.frgraphicsolutions.com/services/

The script is called:

tooltips.js

***It is a javascript that will make the <abbr> tag to become responsive so when a person is viewing the site on a mobile device they can click instead of hover over the object and it will allow them to see the information.***

Unfortunately even though the page is calling the javascript it is not preforming it's function. So the viewer will not be able to see the information at all when on a phone or tablet.

The code reads like this:

jQuery( document ).ready( function($)
    {
    var targets = $( '[rel~=tooltip]' ),
        target  = false,
        tooltip = false,
        title   = false;

    targets.bind( 'mouseenter', function()
    {
        target  = $( this );
        tip     = target.attr( 'title' );
        tooltip = $( '<div id="tooltip"></div>' );

        if( !tip || tip == '' )
            return false;

        target.removeAttr( 'title' );
        tooltip.css( 'opacity', 0 )
               .html( tip )
               .appendTo( 'body' );

        var init_tooltip = function()
        {
            if( $( window ).width() < tooltip.outerWidth() * 1.5 )
                tooltip.css( 'max-width', $( window ).width() / 2 );
            else
                tooltip.css( 'max-width', 340 );

            var pos_left = target.offset().left + ( target.outerWidth() / 2 ) - ( tooltip.outerWidth() / 2 ),
                pos_top  = target.offset().top - tooltip.outerHeight() - 20;

            if( pos_left < 0 )
            {
                pos_left = target.offset().left + target.outerWidth() / 2 - 20;
                tooltip.addClass( 'left' );
            }
            else
                tooltip.removeClass( 'left' );

            if( pos_left + tooltip.outerWidth() > $( window ).width() )
            {
                pos_left = target.offset().left - tooltip.outerWidth() + target.outerWidth() / 2 + 20;
                tooltip.addClass( 'right' );
            }
            else
                tooltip.removeClass( 'right' );

            if( pos_top < 0 )
            {
                var pos_top  = target.offset().top + target.outerHeight();
                tooltip.addClass( 'top' );
            }
            else
                tooltip.removeClass( 'top' );

            tooltip.css( { left: pos_left, top: pos_top } )
                   .animate( { top: '+=10', opacity: 1 }, 50 );
        };

        init_tooltip();
        $( window ).resize( init_tooltip );

        var remove_tooltip = function()
        {
            tooltip.animate( { top: '-=10', opacity: 0 }, 50, function()
            {
                $( this ).remove();
            });

            target.attr( 'title', tip );
        };

        target.bind( 'mouseleave', remove_tooltip );
        tooltip.bind( 'click', remove_tooltip );
    });
    });

I created a function.php for the child theme that has the code only called to on this specific page:

<?php
    if ( !function_exists( 'tool_tips' ) ) {
    function tooltips() {
    if ( is_page( 'services' ) ) {
    wp_enqueue_script( 'tooltips', get_stylesheet_directory_uri() . '/js/tooltips.js', '', '1.0', true );
    }
    }
    }
    add_action( 'wp_enqueue_scripts', 'tooltips' );

    ?>

Like I stated earlier, it has been functioning the past few weeks with no issues (I even checked it over this past weekend) and today I noticed it stopped working.

Since the page is actually calling the script, but it is not functioning I believe there is something wrong with my script or another script is effecting it. I am new to jQuery, so it is harder for me to find issues through the code when I know many here can see pretty easily.

Thank you very much.

[Moderator Note: Please ensure that you are embedding links correctly in your posts.]

Kevin Kwok on "Reference post thumbnial without it linking to post"

$
0
0

Hi all,

I have a need to reference my post's featured thumbnail. I was able to display it no problem with the use of

<?php the_post_thumbnail(); ?>

However I notice it links to the actual post it came from, is it possible to have it just reference the img src itself and now auto attach a link to itself? Thanks in advance.


starapple on "Alternative to query_posts to get categorie and posts info"

$
0
0

Hi and a great day to you.

I've been using with the desired results, query_posts() in the home page of a theme I've been writing, to return specific categories and their posts with titles, permalinks and the attached image. But reading the Codex it advises and warns against using query_posts in themes and plugins. Is there an alternative suitable way (query) to get the info I want? Would it be better to place it in functions.php?

This is what I have:
`$display_categories = array(36,32,21,14,10);
foreach ($display_categories as $category) {
query_posts("showposts=4&cat=$category");
$wp_query->is_category = false;
$wp_query->is_archive = false;
$wp_query->is_home = true;
$category_link = get_category_link( $category );?>`

and
`<h3 class="text_line"><a href="<?php echo $category_link;?>">
<?php // name of each category gets printed
wp_list_categories('include='.$category.'&title_li=&style=none');?>
</a></h3>
<div class="scroller">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>`

to return the_permalink(), the_title_attribute()

Your help will be greatly appreciated.

Msrk.

bicounet on "Disable Admin Bar"

$
0
0

Hello,
I have WP 3.7.1 and I would like to remove the WordPress admin bar that appears at the top .
Someone can delete?
I placed in the theme functions.php file:

remove_admin_bar function () {
show_admin_bar (false);
}
add_action ('after_setup_theme', 'remove_admin_bar');

But it does not work !

Then how to log out of wordpress without admin bar?
Thank you for your help

beltex on "moved wp-config, cant find wp-settings"

$
0
0

Hi i wanted to use an plugin for creating pdf files and i have a reason to choose this specific one.

This plugin needs wp-confi but i moved that outside root, so i change the location in the script.

But then iget a different error
Warning: require_once(/home/snelgoedko/domains/mydomain.com/wp-settings.php) [function.require-once]: failed to open stream: No such file or directory in /home/snelgoedko/domains/mydomain.com/wp-config.php on line 128

There is a reference to wp-settings.php via abspath but it seems not correct?

Is that to be expected if u move the wp-config file, that the abs path does not changed because wp scans for the file but still thinks the abs path should be default in reference to wp-settings ???

wen.wainwright on "Customising a theme"

$
0
0

[Moderator Note: Topic title modified. When you start a new topic, use a good topic title.]

First of all I posted this in a lower level area and I apologize for re-posting it. I would delete it if I could.

I'm using TwentyThirteen and I want to use the optional right hand sidebar on my pages that are "posts." I want to exclude the right hand sidebar for pages that are pages. In the page.php file the <?php get_sidebar(); ?> is located after the content because the main sidebar is just above the footer. There is no other call for the optional sidebar in this template. I figure I could use a custom page.php for the pages so it won't show the right-hand sidebar but I do not know how to write php to unregister or not_get, etc., or where to put it. Again, sorry about the reposting of this question.

Christiaan Conover on "get_current_screen() throws 'undefined function' error"

$
0
0

I'm trying to use the get_current_screen() function in my plugin, but I'm getting an "undefined function" error from PHP when I do. I looked around to see if that function was deprecated but it doesn't appear to be. Any suggestions on how to resolve this?

You can see the error at https://wp.dev.cconover.com/

rboord on "wp_mail “from” header concatenation trouble"

$
0
0

So I've got a problem with wp_mail sending from the wrong e-mail address. I want it to come from a specific user in this case. My code to get the user's e-mail works, because it echoes properly in the $message section.

The problem seems to be my formatting of the concatenation on the $headers section. Here's my mail codes I've tried, to no avail. This first one was from another stackoverflow post.

$headers = "From:" . apply_filters( 'wp_mail_from',$fromEmail);
wp_mail($to, $subject, $message, $headers);

--

$headers = "From:" . $fromEmail;
wp_mail($to, $subject, $message, $headers);

--

$headers = "From: ".$fromEmail."\r\n";
wp_mail($to, $subject, $message, $headers);

I'm ripping my hair out. I have another wp_mail form elsewhere in the site that inputs the $headers variables using the $_POST method, but I'm not using that to get the data. And again, the e-mail echoes in the $message section. So I'm going insane trying to figure out why it's not working.

Walton on "One set of custom meta fields not showing in post"

$
0
0

I'm working on a theme for teachers with a custom post type, lesson plan. For example: http://www.englishadvantage.info/testblog/lesson/writing-good-toefl-paragraphs-quickly/

The info on the right: Goals, Objectives, and Materials are all generated in meta fields I generated. I don't understand why the Goal is showing, the objectives are showing, but the materials aren't showing even though there is information there:

This is the code for that part of the page:

<div id="goal">
<?php if (!empty($goal)) echo "<h3>Goal</h3>","<br>",$goal; ?>

<?php if (!empty($objective1)) echo"<h3>Objectives</h3>","<br>","&#149", $objective1;?>
<?php if (!empty($objective2)) echo "<br>","&#149", $objective2; ?>
<?php if (!empty($objective3)) echo "<br>","&#149", $objective3; ?>

<h3>Materials</h3>
<?php if (!empty($materials1)) echo "<br>","&#149", $materials2; ?>
<?php if (!empty($materials2)) echo "<br>","&#149", $materials2; ?>
<?php if (!empty($materials3)) echo "<br>","&#149", $materials3; ?>
<?php if (!empty($materials4)) echo "<br>","&#149", $materials4; ?>
<?php $args = array(
   'post_type' => 'attachment',
   'numberposts' => -1,
   'post_status' => null,
   'post_parent' => $post->ID
  );
  $attachments = get_posts($args);
     if ($attachments) {
        foreach ($attachments as $attachment) {
           echo "<br>","&#149";
           the_attachment_link($attachment->ID, true);
     }
     };
?>
</div><!--#goal-->

You'll see one listing under Materials, but that is being picked up by the attachment loop at the end.


bublick on "How to debug theme?"

$
0
0

Not long ago I had a trouble with my wp site on nginx. Now I understood what is the error kind of.
It appears on just published posts in wp editor. The page isn't loaded at the end and jQuery isn't loaded too. So I can't debug it with any WP Plugins.
Troubles are going out when I remove line
register_taxonomy( 'basic_cats', 'post', array( 'hierarchical' => 'true', 'label' => 'Simple', 'query_var' => 'true', 'rewrite' => 'true' ) );
from my build taxes function. The last builts also 4 taxes. But the problem going out only when I remove this taxonomy registering function. I'm crazy o.O

So, my question is about how can I get WP's error messege about this line. I don't know why wp don't like it. It just don't load all jQueries and css stylesheet. Does anybody has some means about this?

victor_jonsson on "Best way to create a css file dynamically"

$
0
0

Hi there!

What would be the best way to dynamically generate a stylesheet in a theme? I can think of three different solutions:

1) Having a separate file in theme and assume where the file wp-load.php is located and include it like '/../../wp-load.php'.

2) In the file functions.php check if a certain variable is set and if so generate the stylesheet and terminate the script.

3) Register an ajax function and link to the url of the ajax function (not sure if wordpress checks if AJAX-requests is sent with correct request headers).

Is there any other way to accomplish this? I know that the first solution is most straight forward but I consider it to be something of a hack, especially if it exists a "correct" way of doing it.

/ vic

theMikeD on "will wp_delete_attachment delete all images sizes too?"

$
0
0

The codex doesn't indicate this so I'm wondering if anyone else knows:

There are two basic types of images: the original uploaded image, and the image(s) derived from it for things like thumbnails etc. The derived images are easily identified because they have the filename format

<original>-<width in pixels>x<height in pixels>.ext

When this function is called with the ID of an originally-uploaded image, will all derived images also be deleted? Or will then be left there as clutter?

mrapi on "Hook on download link/accessing menu"

$
0
0

Hi !
I'm new using Wordpress.In my site I have a menu that links directly to a setup file,for downloading.I want to hook an action/filter on writing a function that inserts into a database the time when the setup was downloaded/menu accessed.
I know I could find a plugin but I want to create my own,I also want to customize that on every new week to send info to my mail about last week downloads activity.
All I need now is how to hook that in wordpress?

Thanks!

PGrizz on "Adding a custom field in addition to Post Name to Permalinks?"

$
0
0

By default WordPress takes the page title you enter in the editor and makes it into a permalink. This title is usually also the h1 of the post.

If I keep the default title in the editor as my h1, but then add another h2 that's added by an Advanced Custom Field, how would I be able to combine the custom h2 field into my page's permalink to help my SEO?

For Example: My post's title would be "WordPress Title" and my custom h2 field added to the post would be "Example for Forum" so the url would end up being "site.com/wordpress-title-example-for-forum"

Doesn't seem like it's as easy as just appending the custom field on to the end of /%postname%/ in the Custom Structure of the Permalink settings.

Viewing all 8245 articles
Browse latest View live


Latest Images