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

amybryde on "Modify search results page to table - code for loop?"

$
0
0

The search results page looks horrible and I would like to modify to present a table since the search will mostly be used as a parts search. All inventory has been divided up into categories with 1 category being our Master Inventory list. Unfortunately, since the files are so large, I had to use the "Embed a document" plugin to create most of the pages of inventory.

After must research, I have found that I need to modify the look within the search.php file. My problem is that I am unsure what code to use to have it display correctly as a 6 column table (Part Number, NSN, Alt. P/N, description, condition and quantity) showing only the part number information searched. The data would have to be pulled from the data created from the "Embed a document" plugin. I am simply at a loss of how to create the needed loop to display this correctly so that just the part number search shows up instead of the whole long list of inventory.

As an example, try searching "50-8792-3"

The website is http://www.calportaviation.com.

Any help with the coding would be much appreciated!

Thank you!


the_enn on "Can't stop p tag insertion with shortcode"

$
0
0

So I've read several articles and posts on how to prevent WP from adding <p> in front of <img> tags. Yet, I'm unable to return shortcode content without the p tag being inserted.

My shortcode function looks like this:

function displayAllianceNews($atts, $content = null) {

  $thecontent.='<div>'.$content.'</div>';

  // Get rid of WP <p></p> tags before <img>
  $content_antip = remove_ptags_images($thecontent);
   return $content_antip;
}

The input $content variable doesn't have any <p> tags to start. It looks like:

<h2>News</h2><img src="/wp-content/uploads/2015/04/4.1.5.3-NCCRA-CBL-Cover-e1429193101216.jpg" class="wrapleftOutline" alt="photo">

Here's the filter function (just for the open p tag for testing):

function remove_ptags_images( $string )
{
    $patternOpen = array(
        '#<p>\s*<img>#'
    );

    return preg_replace($patternOpen, '<img>', $string);
}

If I echo $content_antip before the return statement, the content appears correctly with no p's. However, WP seems to be filtering the content after the return statement and adding p's around the img tag. I added these to my functions.php as well, but to no avail:

remove_filter ('acf_the_content', 'wpautop');
remove_filter( 'the_content', 'wpautop' );

Any idea what I'm doing wrong?

villavulavala on "UPDATE using $wpdb in"

$
0
0

I am using php to pre-fill a form with data which should then be actioned on UPDATE. However, the form action does not work, I get error 404. How do I write the code using $wpdb functions ?- or is this even the correct approach ?
I have looked at the codex but don't know how to do it ? I will appreciate any help

eddr on "Can't save compressed string in options table (set_transient/update_option)"

$
0
0

Hi

I'm trying to save big string as a transient and I want to compress it. I've tried PHP's gzcompress and gzencode and I can compress and decompress fine.
However, if I try to save the data in the DB using set_transient or update_option, it fails - no data is stored.
tried PHP 5.6 and PHP 7 and I'm using transients otherwise just fine

Any clue?

Thanks

lottestina on "How to move text box to the right side of the webpage?"

$
0
0

Hi,

I have a problem- a grey text box that used to be in the right side of the page dropped down to the bottom of the page. I think there is something with the code which looks like this right now:

[vc_empty_space height="32px"][vc_column_text css=".vc_custom_1457560839895{border-top-width: 1px !important;border-right-width: 1px !important;border-bottom-width: 1px !important;border-left-width: 1px !important;padding-top: 10px !important;padding-right: 15px !important;padding-bottom: 10px !important;padding-left: 15px !important;background-color: #e2e2e2 !important;border-left-color: #666666 !important;border-left-style: solid !important;border-right-color: #666666 !important;border-right-style: solid !important;border-top-color: #666666 !important;border-top-style: solid !important;border-bottom-color: #666666 !important;border-bottom-style: solid !important;}"]

SUBJECT OF RIGHT SIDE TEXT BOX

My Visual Composer is not working atm, is there any possible ways transfer it with code to the right side of the page?
Thanks!

Chris Huff on "Reading & updating custom field on page via meta box"

$
0
0

This code works on the edit screen for posts, but not on the edit screen for pages. But if I update the custom field manually (selecting the custom field from the dropdown, and entering "yes" as the value) then refresh the page, the check box is checked. But if I uncheck the box and update the post, it's still checked when the page refreshes. It's like it can read the custom field, but not update it. But, like I said, it works perfectly for posts. So I'm wondering if it has do with how pages are stored and accessed vs. how posts are stored? Any ideas?

<label for="afift-disable"><input name="afift-disable" type="checkbox" value="yes"
<?php
    if((!is_array(get_post_custom_keys($object->ID))) || (is_array(get_post_custom_keys($object->ID)) && (!in_array('afift-disable', get_post_custom_keys($object->ID))))){
        if(get_option('auto_image_default_disable') == 'yes'){
            echo ' checked';
            }
        }
    else{
        $checkbox_value = get_post_meta($object->ID, "afift-disable", true);
        if($checkbox_value == "yes"){
            echo ' checked';
            }
        }
    ?>
>Disable for this post</label>

TheLoneDeveloper on "Pull out values from multidimensional associative array"

$
0
0

This is a bit embarrassing but arrays have always given me a run for my money.

I'm creating a plugin where I will give the user the option to select the interval they want a certain feature within my plugin to run.

So I'm pulling all cron schedules currently defined using: wp_get_schedules();


https://codex.wordpress.org/Function_Reference/wp_get_schedules

Then i'm doing this:

$active_cron_schedules = wp_get_schedules();

          print_r(Array_values($active_cron_schedules));

          foreach ($active_cron_schedules as $key => $value) {
            echo $key;
          }

currently it outputs the hourly twicedaily daily my_cron it's not going deep enough, I want to get the "display" so it shows the "nice name" of the schedule.

Help is appreciated, thank you.

howardmcfly on "Widget multiple checkbox update problem"

$
0
0

hi guys,
i'm a newbie in programming and wordpress so i have an big issue i can't solve. i want to write a plugin with a widget which saves the inputs to a database. nearly everything is working but i can't save the multiple checked checkboxes to database. i'm guessing the problem is in update function. so here are the relevant code snippets.

public function form( $instance ) {

$article_exclusion = isset($instance['article_exclusion']) ? $instance['article_exclusion'] : array() ;

		?>

		<p>
			<label for="<?php echo $this->get_field_id('article_exclusion'); ?>"><?php _e('Ausschlussartikel:'); ?></label>

			<div style="height:200px;overflow:auto;border:1px solid #dddddd;margin-top:-10px;">
			<?php
			global $post;
			$args = array( 'numberposts' => -1);
			$posts = get_posts($args); foreach( $posts as $post ) : setup_postdata($post);
			?>
			<input style="margin-top:5px;" type="checkbox" name="<?php echo $this->get_field_name( 'article_exclusion' ); ?>[]" value="<?php the_ID(); ?>" id="<?php the_ID(); ?>" multiple="multiple">
				<label><?php the_title(); ?></label>
			</input>
			<?php endforeach; ?>
			</div>
    }

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

    $instance['article_exclusion'] = strip_tags( $new_instance['article_exclusion'] );

	global $wpdb;
    $table_name = $wpdb->prefix . "anzeigenschalter";
	$wpdb->insert($table_name, array('Kategorie_ID' => $instance['category'],
									'Ausschlussartikel_ID' => $instance['article_exclusion'],
									'Zeitraum_Start' => $instance['begin_duration']));

return $instance;
    }

    public function widget( $args, $instance ) {
        // Frontend display HTML
    }

}

nuriarai on "setting cookies to have last two visited posts"

$
0
0

Hello, I try to set two cookies every time a user visit blog' posts, in order to save the last two visited posts by same user. With this information I have to display in a home section these two last posts, so they well be different for each user. If is first visit I will display two random posts.

I have set a function hooked to init hook that set the two cookies every time the user is visiting a post. But I have some different problems that I can't figure how to resolve on my own.

As in the init hook it is not yet loaded the current post information and neither the is_single function or is_home function, I can't know which page the user is, so I have to take the server url with $_SERVER["REQUEST_URI"]. My function writed in functions.php

1) First problem is if I try to refresh header after setting the cookies. This code is getting ok without the header("refresh:0"), but with the refresh is looping all time and not loading the page, like if exit not running.

function enn_set_cookies() {
	if (!isset($_COOKIE['last_ing_post'])) :
		setcookie('last_ing_post', sanitize_text_field(htmlspecialchars( $_SERVER["REQUEST_URI"], ENT_QUOTES, 'UTF-8' )), time() + 86400, "/");
		header("Refresh:0");
		exit;
	else :
		setcookie('last_ing_post', sanitize_text_field(htmlspecialchars( $_SERVER["REQUEST_URI"], ENT_QUOTES, 'UTF-8' )), time() + 86400, "/");
		setcookie('prelast_ing_post', sanitize_text_field($_COOKIE['prelast_ing_post']), time() + 86400, "/");
		header("Refresh:0");
		exit;
	endif;
}
add_action( 'init', 'enn_set_cookies' );

2) Same code without refressing header is running ok if the user is navigating between posts, but if the user goes to pages or home, then I would need to know if the page is home. The home is getting posts in a general wp_query that are loading with ajax_infinite_scroll. When I set the cookie for home page, it is writing a big string that begins like this:

Value %2Fwp-admin%2Fadmin-ajax.php%3Faction%3Dalm_query_posts%26amp%3Bquery_type%3Dstandard%26amp%3Bnonce%3D9465c1cf3b.....

I don't know how to distinguish if is a page or archive page, but I can try to know if is home by getting only "/" or try strpos if is wp_admin inside the cookie. But if I try this:

$url = $_SERVER["REQUEST_URI"];
	$ishome = strpos($url, "wp_admin");
	if($ishome === false) {
		// if not is home we do our stuff (but we dont know if is a page, so her we have another problem ;
		do set cookies
	} else {
		//if is home we dont touch our cookies, so they remain set with last pots or, if is first time, they remain unset
	}

the variable $ishome never is false, because the strpos never return false as if in the cookie there isn't the "wp_admin" string, but there is it.

Maybe there is another approach to the whole goal I need to achieve, but I can't figure how. Iy anyone has any idea It will be very much appreciated.

alexstrazsa on "Removing sidebar widgets with jQuery"

$
0
0

Hi. I run a blog that sometimes posts content that doesn't comply with AdSense content policies, so I decided to make a shortcode that I can add into specific posts which will remove the AdSense ads from that post.

I'm using the GeneratePress theme, and the code works just fine for the Ad Unit above my posts, which is contained in its own and implemented via the GenerateHooks plugin. It does not, however, work for anything on the sidebar.

This is the entirety of the plugin code:

<?php
/*
Plugin Name: Hide Ads
Plugin URI:
Description:
Version:
Author:
Author URI:
License:
License URI:
*/

function remove_ads() {

?>
<script>
  jQuery( ".fgkbsdkgjhbsgjds, .text-4, .text-11" ).remove();
</script>
<?php

}
add_shortcode( 'remove_ads', 'remove_ads');

The first element there, ".fgkbsdkgjhbsgjds", gets removed as it should, while the others aren't affected at all.

I suspect it has something to do with the sidebar widgets being "aside" classes instead of typical div classes, and I'm not sure how to remove something like that. I've tried this as well:

jQuery( "aside" ).remove( ".text-4" );

And it doesn't change anything.

Anyone have an idea?

rikdegraaf on "Add post through code, visibility on front end"

$
0
0

Hi everyone,

I am writing a plugin and in the plugin I want to create a post in a custom post type with wp_insert_post and update_field(Advanced Custom Fields).
The post gets added and shows in admin but not on the frontend.
It only works when manually updating the post in admin.
I allready tried adding visibility.

This is my code:

$reservering = array(
      'post_title'    => ''.time().'',
      'post_content'    => 'Reservering',
      'post_status'   => 'publish',
      'post_type'   => 'reserveringen',
      'post_author'    => 1
    );

    // Insert the post into the database
    $post_id = wp_insert_post( $reservering );
    update_post_meta( $post_id, '_visibility', 'visible' );

    $sloep = willekeurigBeschikbareBootOpLocatie($_POST['boekingsdatum'],$_POST['dagdeel'],$_POST['locaties']);

    update_field('dag', $_POST['boekingsdatum'], $post_id);
    update_field('dagdeel', $_POST['dagdeel'], $post_id);
    update_field('dagdeel_sloep', $sloep, $post_id);
    update_field('geslacht', $_POST['manvrouw'], $post_id);
    update_field('voornaam', $_POST['voornaam'], $post_id);
    update_field('achternaam', $_POST['achternaam'], $post_id);
    update_field('postcode', $_POST['postcode'], $post_id);
    update_field('plaats', $_POST['plaats'], $post_id);
    update_field('telefoon', $_POST['telefoon'], $post_id);

I tried searching the internet, but all suggestions always point to visibility.

I hope you guys have any idea what to do.

Thanks,
Rik

mae48 on "Prevent bootstrap modal from closing"

$
0
0

Hi, I have created my bootstrap modal form in my product page...My problem is that, it didn't load on the modal form...It keeps on closing whenever I press submit...I want it to be loaded on the modal form not the entire page....
Can someone help me deal this problem??THanks

markverduffelt on "script is working, but i think not in wordpress style"

$
0
0

Hi,

My script is working, but please will someone look at my code, and give me tips in what way i can improve the quality? Because I think it is not in wordpress style:

http://codepaste.net/pobxj7

Thanks

anamalagabara on "Thumbnail editing inside a catalog plug-in - looking for help"

$
0
0

I've had a customization of the huge-IT catalog plug-in for my website. However, I'm not able to work with the thumbnail view and the developers of the plug-in won't assist me any further. I'm looking for help with this issue, willing to hire a developer that can take care of it. I've tried the plug-ins Post-thumbnail-editor and Yoimages. Their interface seems like exactly what I need but it does not affect the image displayed by the catalog. You can see the problem here: http://www.architecturalaccents.com/AAwordpress/mantels/

xennox on "WooCommerce } Hide particular categories in the single product page"

$
0
0

Hello,
I want to hide some category names in the single product display page. I only want the subcategories to show up here, without the top category.
Your help is greatly appreciated, thank you.


ajia.im on "HTTP Response Shows Spam Links but Cannot Locate?"

$
0
0

I have an issue with the website ethicalclothingaustralia.org.au

When I rendered it using Google Webmaster Tools it shows the below nasty code (I'll just copy and paste the top few line as there as a large amount).

<-- WordPressSEOPlugin --><a href="http://pendrive.reklamowe.net.pl/?get-cash-fast-no-credit-checkamphionpro.688883&works=3&workid=68888">Can i earn money by internet</a>
<a href="http://pendrive.reklamowe.net.pl/?how-to-make-real-money-online-for-freedienthoaiben.227392&works=2&workid=22739">Easiest ways to earn money online uk</a>
<a href="http://pendrive.reklamowe.net.pl/?get-cash-fast-no-credit-checkamphionpro.679843&works=3&workid=67984">Online money jobs work legit</a>
<a href="http://parasole.reklamowe.net.pl/?earn-cash-at-homecraton.702862&works=2&workid=70286">Earn money for doing survey jobs</a>
<a href="http://ecofriendlymag.com/?free-way-to-make-moneycubssuckclub.3260618&works=18&workid=32606">How much money can you make youtube partner</a>

I tried to locate WordPressSEOPlugin but it doesn't seem to be installed.

I also searched for links in every single file in the website's directory but could not find any files that contain them.

Any ideas on why these are showing when I fetch them in Google and how I can locate and remove them?

Thanks in advanced!

Freelancealot on "Ordering Child Term Headings with list of posts in Custom Tax archive"

$
0
0

Hi,

I am building a business listings site using custom post type (goto_listing) and custom taxonomy (business-categories).

I have set up templates for the taxonomy archive pages for each (parent) term (e.g. taxonomy-business-categories-fabrication.php)

On these archives I want:

Under the parent term title (eg Fabrication) I want the child terms as h3 headings and the listings (custom posts) underneath.

I have achieved this but currently only the post titles are in alphabetical order. Their headings (child terms) appear to be ordered by the date (for some reason).

Here is the code that gets the current parent term it's child terms and the related posts:

<?php
    $term_slug = get_query_var( 'term' );
    $taxonomyName = get_query_var( 'taxonomy' );
    $current_term = get_term_by( 'slug', $term_slug, $taxonomyName );
    $termchildren = get_term_children( $current_term->term_id, $taxonomyName );
    foreach ($termchildren as $child) {
    $term = get_term_by( 'id', $child, $taxonomyName );
        $wpq = array (
        'post_type' => 'goto_listing',
        'taxonomy'=>$taxonomyName,
        'term'=>$term->slug,
        'posts_per_page'=>'20',
        'orderby'=>'title',
        'order'=>'ASC'
        );
        $query = new WP_Query ($wpq);
        echo "<h3>$term->name</h3>";
        ?>

	<ul class="goto-leaders">
        <?php
        if ($query->have_posts() ) : while ($query->have_posts() ) : $query->the_post(); ?>

<li><span><?php the_title();?></span><span><?php echo CFS()->get( 'goto_telephone' ); ?></span></li>
        <?php endwhile;  wp_reset_postdata(); ?>
</ul>

The result is:

Child Term B
A Business
B Business
C Business

Child Term A
A Business
B Business
C Business

Child Term C
A Business
B Business
C Business

I need it to be:

Child Term A
A Business
B Business
C Business

Child Term B
A Business
B Business
C Business

Child Term C
A Business
B Business
C Business

Basically I need an orderby 'term name' order ASC but after many many many hours I have been unsuccessful.

It seems like such a simple task, maybe I'm overcomplicating it?

Thanks for any help you can give.

Cheers,
Tracy

Diego on "Syntax error while updating SVN repository"

$
0
0

I'm trying to upload an updated version of one of my plugins, and the commit fails due to a "syntax error":

Commit blocked by pre-commit hook (exit code 1) with output:
PHP Parse error:  syntax error, unexpected '.', expecting ')' in - on line 10

The code is generated by Composer, and it works fine in PHP 5.3 and later. I reckon that the error is due to a rule that applies to PHP 5.2 and earlier.

Affected code

<?php

// autoload_static.php @generated by Composer

namespace Composer\Autoload;

class ComposerStaticInit9b09a05c4e06ffb39df7e3d597db9ef6
{
  public static $files = array (
    // This the affected line. The error is probably caused by the
    // fact that in older versions of PHP it was not possible to
    // use concatenation in variable and property declarations
    '1d1b89d124cc9cb8219922c9d5569199' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
  );

  // Other code...
}

The plugin is designed to check for PHP 5.3 or later, and it won't run without it, therefore the syntax is valid. Is there a way to skip this pre-commit hook?

JeroenBalk2 on "Creating a page used for dynamic form loading"

$
0
0

Hello there.

I'm using my own theme in combination with Bootstrap and I use the Bootstrap Modal to dynamically load forms made in Ninja Forms.

So what I'm doing is, my modal is opened with a given parameter: form_id. Like this: <iframe src="http://domain.com/formdisplayer?form_id=23"></iframe>

I'm using an iframe because it supports all the ajax features I like to use. I can't load the Ninja Forms with ajax directly because it'll cause ajax validation to be broken.

Anyway: now, for my solution to work I need to have a page in my pagelist with slug 'domain.com/formdisplayer' and a custom template called formdisplayer.php. I don't like this because my client can also take a look at the pagelist. Is it possible to make the page 'formdisplayer' accessible with pure coding and no instance at the pagelist in wp-admin? I also don't want the formdisplayer template be available to my contentmanagers.

joelsantos86 on "featured image external url"

$
0
0

Hey.
can someone help with something. I want to put the image of feature image to redirect to a diferente url. Im using the accesspress parallax theme but they dont have that function on the service-section (the section with some feautures images that i want to redirect). Im not a pro coder but i think i can manage myself. all the help would be appreciated.

Viewing all 8245 articles
Browse latest View live




Latest Images