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

Trinacy on "Find out who commented"

$
0
0

I need a way to find out who commented during a specific time period. Is there a way to display this result?

I've tried using;

<?php
$args = array(
	'user_id' => 1, // use user_id

);
$comments = get_comments($args);
foreach($comments as $comment) :
	echo($comment->comment_author . '<br />' . $comment->comment_content);
endforeach;

But I can't seem to get it to work for me.


cluesew on "Password Protect Page Template to Show Only Posts from One Category (1 post)"

$
0
0

Since it isn't possible to password protect a Category template or page, I'm trying to display the_content() of posts for 1 category on a page that is password protected.

So far, I can only get the_content() to display when using query_posts('cat=10') which everyone is saying to avoid these days. However, it will not prompt for a password that I have set for the page. Here's the code being used:

<?php query_posts('cat=10'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<dt><?php the_content(); ?></dt>
<?php endwhile; endif; ?>

Searching around, I tried the below method. Password prompt appears, but after that, the page is empty:

<?php if(!empty($post->post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {
			the_content(); // used to display password form
		}

		if (isset($_COOKIE['wp-postpass_' . COOKIEHASH]) && $_COOKIE['wp-postpass_' . COOKIEHASH] == $post->post_password) {

			query_posts('cat=10');
			 if ( have_posts() ) : while ( have_posts() ) : the_post();
			 the_content();

			 endwhile; endif;
		} ?>

I also tried this method in my functions.php file and nothing displays on the page either:
function comm_archive_category( $query ) { if ( $query->is_page( 'commercial-archive' ) && $query->is_main_query() ) { $query->set( 'cat', '10'); } } add_action( 'pre_get_posts', 'comm_archive_category' );

Lastly, I tried the recommended method to no avail either. If I change the_content() to the_title() it does show the posts's titles, but I need to show the_content():

<?php
$query = array (
    'posts_per_page' => 10,
    'cat' => 10
);
$queryObject = new WP_Query($query);
if ( have_posts() ) : while ( have_posts() ) : the_post();
the_content();
endwhile; endif;
?>

I'm beginning to think this isn't possible. Any help would greatly be appreciated. I can provide URLs to the site if needed. Thank you.

87arya on "How to define the sharing icons position with CSS"

quenenni on "get plugins version from outside a WP instance"

$
0
0

Hello,

I'm hosting lots of wordpress with different versions and of course, tons of plugins / themes (lots of different version too).

We're trying to implement scripts to get all WP versions and plugins / themes versions in order to detect the ones that are not up-to-dated.

I already tried the excellent wpsan tool (https://github.com/wpscanteam), but unfortunately, it only work with an url and not within the system (with a internal path as param) and that's just not possible with all the WP we have.

I already built a script to have all the WP versions and another one to have all the plugins versions and they work nice and quick.

Now, I would like to know the last version of each plugin we are using to be able to compare with the one we have. I checked the plugin API but couldn't make it work.
All my attemps gave me the answer:
O:8:"stdClass":1:{s:5:"error";s:22:"Action not implemented";}

As far as I understand, we have to use it from inside a WP.

Does anyone know if it possible to call the API from an external script (outside a WP instance).
I using Python, but if it's only possible with PHP, I can manage that.

My search on the net returned nothing.
Maybe someone knows where I can find an example on how to do it.

Thanks

hughbalboa on "ANTI scriptinjection on Templates-Pages MySQL"

$
0
0

Hi, using MYSQL on TEMPLATES for PAGES on wordpress

is their a safe mode to INSERTO INTO , UPDATE and DELETE, without Hacking codes like Anti scriptinjections

i need help please

thank you

jpwordpress on "Display Dynamic Phone Number throughou Entire Website"

$
0
0

Hello everyone,

I have built a website with links to multiple pages in WordPress. On each of those pages a phone number is listed. I am running several different online campaigns and each of those campaigns has an Affiliate ID that is passed through tracking links when a user clicks them. I would like to display a phone number that corresponds to the different Affiliate ID throughout my entire website.

For example, for if a user clicks on a tracking link from Affiliate ID A, then Phone Number A displays. When a user clicks on a tracking link from Affiliate ID B, then Phone Number B displays.

I know how to code this up in a single page HTML/CSS website using PHP and switch statements; however, I am having difficulty implementing this in WordPress.

Currently in my Word Press website, when a user clicks a tracking link, the dynamic phone number can only be displayed on the landing page.

Basically, the Affiliate ID information is lost and the default phone number is displayed when a user navigates within the website.

How can I make a dynamic phone number based on a tracking link's affiliate ID appear consistently throughout my website?

Angelo Rocha on "Custom Post Type"

$
0
0

Is possible attach a custom post type in a settings page? The objective was create an area of relational custom post types.

gloskimmer on "Help. I've been hacked"


7Farmgirls on "Search to show full post"

$
0
0

I am creating a blog for a friend here: http://cathyflorence.com, using a Child Theme of 2012.

She is wanting the posts that show up when you search to show the picture that goes with the post. I can't figure out how to either:

1. make the excerpt show the picture
OR
2. just make the search show the whole post, because I am putting 'read more' tags in each post anyway (like the homepage and categories show), so when people scroll through, they won't actually be scrolling through the whole post.

I tried taking out this part of content.php:
is_search() || is_home() || is_archive()
but that was a mistake :)

Then I tried taking this whole part out, and that was also a mistake!

<?php if ( is_search() || is_home() || is_archive() ) :// Only display Excerpts for Search, Home, and Archives ?>
		<div class="entry-summary">
			<?php the_excerpt(); ?>
			<a href="<?php echo get_permalink(); ?>" >Read More &rarr;</a>
		</div><!-- .entry-summary -->

Thanks for any help!

Brain916 on "Delete Old Thumbnail Images?"

$
0
0

Hey everyone,

I wanted to delete old thumbnail sizes as well as the images created by WordPress core. I have over 180,000 images on my server, and each image has roughly 3-4 different dimensions.

I tried a few plugins like DNUI and Image Cleanup, but this would take months for me to do. Is there a way to run something in MYSQL or something to delete the images for specific image sizes?

jbkeefer on "User Geolocation Lat Lon stored in User Profile"

$
0
0

I have used two plugins that can store user lat lon values as user meta data, but they are often parts of a larger map or geopost solution. I don't need to geotag posts or place maps, that is handled, I just simply need the user lat lon.

I wanted to look into acquiring or constructing a geolocation plugin that can plug the lat lon values (browser based) into the user profile upon login.

I have searched high and low and thought I would ask the community for some help before I embark on creating my own. Any suggestions are greatly appreciated.

Jamie

desi_terz on "Unkown text format - Footer section"

$
0
0

Hi. Few days ago I logged in my admin page and I noticed that a plugin that I had installed - its homepage - displayed even in post admin page. So I deleted by using ftp. Then I noticed the footer section of the website as you can see here: wwww.kinesis-gym.gr
I also found an "extra" admin, I deleted the user and change pass etc. I dont understand if this is a problem link to the plugin, or css issue.
Any ideas?

the daniels on "Add Custom Header per property type"

$
0
0

I need to add a custom header image for each property category/type I've managed to change the default header for property types so maybe there's a way to repeat this and assign them to certain categories? Im not sure this is new to me. Any help would be awesome thanks.
Here's the code:

<?php
    // Banner Image
    $banner_image_path = get_default_banner();

    // Banner Title
    $current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    $banner_title = $current_term->name;

    // Banner Sub Title
    $banner_sub_title = $current_term->description;
    ?>

    <div class="page-head" style="background-repeat: no-repeat;background-position: center top;background-image: url('http://blackbirdproperties.co.za/retail/wp-content/uploads/2015/06/Shops-copy.jpg'); background-size: cover; ">
        <?php if(!('true' == get_option('theme_banner_titles'))): ?>
        <div class="container">
            <div class="wrap clearfix">
                <h1 class="page-title"><span><?php echo $banner_title; ?></span></h1>
                <?php
                if($banner_sub_title){
                  ?><p><?php echo $banner_sub_title; ?></p><?php
                }
                ?>
            </div>
        </div>
        <?php endif; ?>
    </div><!-- End Page Head -->

famouswolluf on "Filter products by price"

$
0
0

With pre_get_posts I extend the query with filters.
I'm now trying to make a custom price filter, because i can't use the original filter

De code i'm using:

$minprice = 0;
$maxprice = 0;
if ( isset( $_GET['min_price'] ) && $_GET['min_price'] > 0 ) $minprice = $_GET['min_price'];
if ( isset( $_GET['max_price'] ) && $_GET['max_price'] > 0 ) $maxprice = $_GET['max_price'];

if ( $minprice > 0 || $maxprice > 0 ) {
	$compare = '=';
	$metavalue = '';
	if ( $minprice > 0 && $maxprice > 0 ) { $compare = 'between'; $metavalue = array( $minprice, $maxprice ); }
	if ( $minprice > 0 && $maxprice <= 0 ) { $compare = '>='; $metavalue = $minprice; }
	if ( $maxprice > 0 && $minprice <= 0 ) { $compare = '<='; $metavalue = $maxprice; }

	$query->set( 'meta_key', 'price' );
	$query->set( 'meta_value', $metavalue );
	$query->set( 'meta_compare', $compare );
}

The problem is that if i fill in 10 for min_price i also get 2 euro products.
I know WP is comparing the values as string.
How can I make it numeric?

evFusion on "Output only child pages"

$
0
0

Good day!
There is a task to list the child pages.
There menu:
- Page 1
- Page 11
--- Page 111
--- Page 112
If use the function, with reference to page 11:

function wpb_list_child_pages_of_child() {
    global $post;
        if ( is_page() && $post->post_parent )
         $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
        else
            $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
            if ( $childpages ) {
                $string = '<ul>' . $childpages . '</ul>';
            }
            return $string;
}

is displayed: - Page 11
- Page 111
- Page 112
A need only 111 and 112.
exclude id = page 11, does not work because It excludes 11,111 and 112 together.

How can I convert function?
Thank you!


jaycbrf on "More than one Bootstrap Carousel with shortcode?"

$
0
0

I have created a custom post type for my Bootstrap theme to create a Bootstrap Carousel and shortcode to place a carousel on a page.

Problem is I would like to have multiple carousels on my site but can only create 1 with my code.

How do I modify code to be able to create multiple carousels and place with shortcode like [carousel id="xx"]?

Here is my code :

function jd_bs_theme_setup() {
      add_image_size( 'jd_bs_carousel_image', 1170, 385, true);
  }
  add_action( 'after_setup_theme', 'jd_bs_theme_setup' );

  // Creates Carousel Image Custom Post Type
      add_action( 'init', 'register_jd_bs_carousel_image' );
      function register_jd_bs_carousel_image() {
      $labels = array(
      'name' => _x( 'Carousel Images - use shortcode[carousel] to insert into page or post', 'carousel_image' ),
      'singular_name' => _x( 'Carousel Image', 'carousel_image' ),
      'add_new' => _x( 'Add New', 'carousel_image' ),
      'add_new_item' => _x( 'Add New Carousel Image', 'carousel_image' ),
      'edit_item' => _x( 'Edit Carousel Image', 'carousel_image' ),
      'new_item' => _x( 'New Carousel Image', 'carousel_image' ),
      'view_item' => _x( 'View Carousel Image', 'carousel_image' ),
      'search_items' => _x( 'Search Carousel Images', 'carousel_image' ),
      'not_found' => _x( 'No carousel images found', 'carousel_image' ),
      'not_found_in_trash' => _x( 'No carousel images found in Trash', 'carousel_image' ),
      'parent_item_colon' => _x( 'Parent Carousel Image:', 'carousel_image' ),
      'menu_name' => _x( 'Carousel Images', 'carousel_image' ),
      );
      $args = array(
      'labels' => $labels,
      'hierarchical' => false,
      'description' => 'Images for Bootsrap Carousel',
      'supports' => array( 'title','thumbnail','excerpt' ),
      'taxonomies' => array( 'category' ),
      'public' => true,
      'show_ui' => true,
      'show_in_menu' => true,
      'menu_position' => 20,
      'menu_icon' => 'dashicons-images-alt',
      'show_in_nav_menus' => true,
      'publicly_queryable' => true,
      'exclude_from_search' => false,
      'has_archive' => true,
      'query_var' => true,
      'can_export' => true,
      'rewrite' => true,
      'capability_type' => 'post'
      );
      register_post_type( 'carousel-image', $args );
      }

  function jd_bs_carousel($atts) {
     // Set Shortcode Attributes
     extract(shortcode_atts(array(
        'posts' => -1,
     ), $atts));

     // Start the Return String
     $return_string = '<div id="jd_bs_carousel" class="carousel slide carousel-fade"  data-ride="carousel">

   <div class="carousel-inner" >';

     // starting a new variable for indicators!
             $indicators = '<!-- Indicators -->
          <ol class="carousel-indicators" >';

  // The query
             $the_query = new WP_Query(array(
             'post_type' => 'carousel-image',
              'posts_per_page' => $posts,
              ));
              $i = 0;

             // The loop
             while ( $the_query->have_posts() ) :
                $the_query->the_post();
                  if ( $i == 0 ) {
                $return_string .= '<div class="item active">'.get_the_post_thumbnail($the_query->post->ID,'jd_bs_carousel_image').'<div class="carousel-caption">
              <h1>'.get_the_title().'</h1>
              <p>'.get_the_excerpt().'</p>
             </div>
             </div><!-- item active -->';

                                // The first indicator!!
             $indicators .= '<li data-target="#jd_bs_carousel" data-slide-to="0" class="active"></li>';
                }
                 else {
                  $return_string .= '<div class="item">'.get_the_post_thumbnail($the_query->post->ID,'jd_bs_carousel_image').'<div class="carousel-caption">
              <h1>'.get_the_title().'</h1>
              <p>'.get_the_excerpt().'</p>
             </div>
             </div><!-- item -->';
                 // Continue the indicator var
             $indicators .= '<li data-target="#jd_bs_carousel" data-slide-to="'.$i.'"></li>';
                               }

             $i++;
             endwhile;
             wp_reset_postdata();

                             // Finishing up the indicators var and add it to $return_string
             $indicators .= '</ol>';

             $return_string .= $indicators;

             // Finish the Return String and Clean Up
     $return_string .= '</div>

       <!-- Controls -->
    <a class="left carousel-control" href="#jd_bs_carousel" role="button" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#jd_bs_carousel" role="button" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>';

     return $return_string;
  }

  add_shortcode('carousel', 'jd_bs_carousel');

Please help, I need to complete this project ASAP

kuukuu on "Please delete"

bananabear on "Custom random permalink for posts"

$
0
0

Hi,

I'm using a custom post type and would like to be able to have randomly-generated urls for each post. Is there a way to set an arbitrary permalink for a post in code, after or when I create the post with wp_insert_post?

I know it's possible to manually edit the permalink through the 'Edit Post' page, but I'd prefer to do it programmatically if possible.

ahowell88 on "unset title-tag in post columns?"

$
0
0

So I have a post type that I am trying to remove the title tag column from but its not working. I have a couple of other columns I've removed using the function so it's only this part of the code that is not working.

unset($columns['title-tag']);

The original function is here for reference

function my_columns_filter( $columns ) {
   unset($columns['tags']);
   unset($columns['page-meta-robots']);
   unset($columns['title-tag']);
   return $columns;
   }

Did I not use the correct string for the title tag?

imranforu on "My website block by avast & it's showing the infected file is admin-ajax.php ."

$
0
0

I am facing a problem with my wordpress ecommerce site. When someone try to visit my site it's blocked by avast. And it's showing the malicious problem is admin-ajax.php file. I am not able to recognize which code need to remove. Can you please help me? I have tried so many blog but not found exact solution. I want my site will work with avast antivirus without any block.

I have scan my site using sucuri plug in and its showing no malicious found and site is clean. so why people unable to visit my site when using avast?

Viewing all 8245 articles
Browse latest View live




Latest Images