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

inspiredwp2013 on "get the title from current loop of flexslider"

0
0

Hi i have this code of flexslider written in featureflexslider.php

<?php
   // Get all sticky posts, but only sticky posts
   $sticky = get_option( 'sticky_posts' );
   $args = array(
        'numberposts' => 6, // Display up to 6 posts. Change at will
        'post__in'  => $sticky
         );
	$postQuery = get_posts($args);
        foreach( $postQuery as $post ) : setup_postdata($post);

          if ( has_post_thumbnail() ) { ?>
	    <li>
		<a href="<?php echo get_permalink(); ?>" title="Go to <?           php echo the_title(); ?>" rel="bookmark">
	       <?php the_post_thumbnail('feature-slider'); ?>
		<p class="flex-caption"><?php the_title(); ?></p>

		</a>
	    </li>

    <?php}
	endforeach; ?>

now i want the current title of the flexslider to appear outside the <ul class='slides'> but i don't know how to do it. this is my code in my header.php file

<div id="featured_posts">
  <div class="flexslider">
    <ul class="slides">

	<?php get_template_part( 'featureflexslider' ); ?>
   </ul>
  </div>
    <?php //I WANT THE CURRENT POST TITLE TO APPEAR HERE ?>
</div>

SEO_Statiko on "New to WP Trying to create a page link to another landing page"

0
0

Like the title says i am new to WP and i know basic coding and every client ive dealt with usually have all the coding on each page that i need to Optimize with content and what not.

With the client im helping out at the moment it seems like whoever set it up has all the coding else where for each page including the Home Page which shows very little content when i find it through "Pages" when im going through the wp-admin but it has plenty of content when you are actually looking at it.

And i found most of the content i needed from the "appearance" and clicking "Editor" but my question is how do i add a fancy link from the homepage to a different landing page.

I probably need to give more detailed information for anyone to help me so i apologies for not knowing enough about WP to give more detailed information but if anyone has advice id be really thankful :)

bkeetman on "Disable switching to mobile theme from certain theme pages"

0
0

I am working on a WordPress plugin and theme which does a template switch if server side it is detected the user is visiting the site via a mobile device.

Something like this:

$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$iemobile = ( strpos($_SERVER['HTTP_USER_AGENT'],"iemobile") || strpos($_SERVER['HTTP_USER_AGENT'],"IEMobile") );

if ( ( $iphone || $android || $palmpre || $ipod || $berry !== FALSE || $iemobile ) === true )
{
   // echo 'going to mobile';
    add_filter('stylesheet', function() {
        return '2012aanbiedingen-mobile';
    });
    add_filter('template', function() {
        return '2012aanbiedingen-mobile';
    });
}

So there is a separate desktop theme and a mobile theme.
Obviously I want to switch to the correct theme (mobile or desktop) via the plugin.. so before I actually load one of them. (Or I would always be loading the desktop one.. and some times switch to the mobiel theme).
This all works fine for now.

But now I am planning to move some pages over to be responsive. What I ideally would like to do is set a variable (or execute a hook what ever) in the top of the theme which will let the plugin know.. "no need to switch to the mobile theme. Keep the desktop version."

What would be the best way to handle this?
Are there specific hooks that could help?
Would I always need to render the desktop theme and then decide if the theme needs to switch to mobile etc.

Any advice would be great :)

waraulin on "Business Directory Plugin csv-export.php modification"

0
0

Hello!

I'm trying to alter the csv-export.php file in the Business Directory Plugin in order to make the csv export only export the business emails without any of the other listing info (name, phone #, address, etc).

I have experience coding other languages so I feel like this should only take a simple if statement or modification to the location in the array but I know little to no php so I'm struggling trying to figure this out.

I believe this is the section of the csv-export that I need to change:
`// Setup columns.
$fields = wpbdp_get_form_fields();
foreach ( $fields as &$f ) {
$this->columns[ $f->get_short_name() ] = &$f;
}`

So again, all I want to do is export only the business emails column, which I'm assuming would be at position 7 in the array. I'm not sure if the $fields array is an integer array or string array, I'm thinking it might be strings of the field names because I tried putting in different integer positions in there and the csv export resulted in a blank file.

Here are all of the fields/columns:
business-name business-genre short-business-description long-business-description business-website-address business-phone-number business-fax business-contact-email business-tags

Thanks a lot!
-Will

joser on "Website hacked by HackEd By P4Kurd-TeaM ~NeT.Defacer was here"

0
0

Hello there

My WP website has been hacked by

HackEd By P4Kurd-TeaM ~NeT.Defacer was here :net.defacer7@gmail.com

Has this happened to anyone?, How do I get rid of it?

On my WP log in screen the title tag says the same thing Hacked by P4Ku........

When I log in, the title tags are still hacked and also in the WP dashboard, at the top, right after the house icon, it says the same thing, Hacked by P4Ku........

If you log out WP and view the site live, the title tags seem to be fine, it is only when you are logged in into WP

I have tried to search for a fix but I can't seem to find anything.

Anyone can help?

Thanks a lot

Jose

Niura on "xml importing"

0
0

hi, hoping to pick the right section of the support forum i have these things to ask about...

i have to import file from an XML not created by wordpress so i try to make the one passed to my similar to the wordpress one... i'm quite done, but i have one last issue...

in the theme i use there's a custom field about thumbs and i don't understand how this works...

the a parameter is the number of pic
i is the current image
and s??? is a parameter of my theme or is a parameter of wordpress? and if is a WP what is this?

example :

<wp:postmeta>
<wp:meta_key>thumbs</wp:meta_key>
<wp:meta_value><![CDATA[a:6:{i:0;s:75:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-1-300x201.jpg";i:1;s:75:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-2-300x201.jpg";i:2;s:75:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-3-201x300.jpg";i:3;s:75:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-4-300x201.jpg";i:4;s:67:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-5.jpg";i:5;s:67:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2915-6.jpg";}]]></wp:meta_value>
<wp:postmeta>
<wp:meta_key>thumbs</wp:meta_key>
<wp:meta_value><![CDATA[a:7:{i:0;s:80:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-1-sogg-300x225.jpg";i:1;s:82:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-2-cucina-300x225.jpg";i:2;s:81:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-3-antib-225x300.jpg";i:3;s:81:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-4-bagno-225x300.jpg";i:4;s:80:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-8-matr-300x225.jpg";i:5;s:83:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-12-camera-300x225.jpg";i:6;s:83:"http://www.trovacasa.ra.it/WP/wp-content/uploads/2014/03/2914-15-sottot-225x300.jpg";}]]></wp:meta_value>
</wp:postmeta>

ZeeRuX on "Modified Popular Widget (Elegant Themes)"

0
0

So.. Im having a widget from ET that I have changed so it shows random posts. But since I have change they way Im writing in my posts I only want to show posts that are written after 1th January 2013. Can someone pls help me with this. I have been trying for ever to find help for this. I paste my code here. Also, Im not using any boxes or anything like that on the widget, just the code here.

<?php class PopularWidget extends WP_Widget
{
    function PopularWidget(){
		$widget_ops = array('description' => 'Displays Popular Posts');
		$control_ops = array('width' => 400, 'height' => 300);
		parent::WP_Widget(false,$name='ET Popular Widget',$widget_ops,$control_ops);
    }

  /* Displays the Widget in the front-end */
    function widget($args, $instance){
		extract($args);
		$title = apply_filters('widget_title', empty($instance['title']) ? 'Popular This Week' : $instance['title']);
		$postsNum = empty($instance['postsNum']) ? '' : (int) $instance['postsNum'];
		$show_thisweek = isset($instance['thisweek']) ? (bool) $instance['thisweek'] : false;

		echo $before_widget;

		if ( $title )
			echo $before_title . $title . $after_title;

?>

<?php

	$additional_query = $show_thisweek ? '&year=' . date('Y') . '&w=' . date('W') : '';

	query_posts( 'post_type=post&posts_per_page='.$postsNum.'&orderby=rand' . $additional_query ); ?>
	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
		<div class="blog-entry">
			<a>" class="comments"></a>
			<h4 class="title"><a>"><?php the_title(); ?></a></h4>
			<p class="meta-info"><?php the_time('j F Y'); ?></p>
		</div>
	<?php endwhile; endif; wp_reset_query(); ?>

<?php
		echo $after_widget;
	}

  /*Saves the settings. */
    function update($new_instance, $old_instance){
		$instance = $old_instance;
		$instance['title'] = sanitize_text_field($new_instance['title']);
		$instance['postsNum'] = (int) $new_instance['postsNum'];
		$instance['thisweek'] = 0;
		if ( isset($new_instance['thisweek']) ) $instance['thisweek'] = 1;

		return $instance;
	}

  /*Creates the form for the widget in the back-end. */
    function form($instance){
		//Defaults
		$instance = wp_parse_args( (array) $instance, array('title'=>'Popular Posts', 'postsNum'=>'','thisweek'=>false) );

		$title = $instance['title'];
		$postsNum = (int) $instance['postsNum'];

		# Title
		echo '<p><label for="' . $this->get_field_id('title') . '">' . 'Title:' . '</label><input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . esc_attr( $title ) . '" /></p>';
		# Number of posts
		echo '<p><label for="' . $this->get_field_id('postsNum') . '">' . 'Number of posts:' . '</label><input class="widefat" id="' . $this->get_field_id('postsNum') . '" name="' . $this->get_field_name('postsNum') . '" type="text" value="' . esc_attr( $postsNum ) . '" /></p>';	 ?>
		<input class="checkbox" type="checkbox" <?php checked($instance['thisweek'], 1) ?> id="<?php echo $this->get_field_id('thisweek'); ?>" name="<?php echo $this->get_field_name('thisweek'); ?>" />
		<label for="<?php echo $this->get_field_id('thisweek'); ?>"><?php esc_html_e('Popular this week','Aggregate'); ?></label>
		<?php
	}

}// end AboutMeWidget class

function PopularWidgetInit() {
  register_widget('PopularWidget');
}

add_action('widgets_init', 'PopularWidgetInit');

?>

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

Lindakh5 on "Removing image from facebook plugin"

0
0

I would like to remove the image that my facebook feed is pulling from my blog. How do I change the facebook code to remove the image? My site is http://www.women2womenonline.com,

Thanks!


hopetommola on "Hide part of meta if in specific category"

0
0

I am making an archive of minutes and agendas. Agendas only live in the system until the meeting is held, so I am using the Published Date as the "Meeting Date" in order to organize the post archives properly.

As such, I've modified the theme's entry-meta to show:
Filed under: %1$s <br />Meeting date: <a href="%3$s">%7$s</a>

But, I need to hide the Meeting date: <a href="%3$s">%7$s</a> portion of the post meta if the category is Agendas - in both the content.php and content-single.php files of my twentyeleven child theme.

Any assistance greatly appreciated.

charlesdunworth on "php echo a title above my list of related posts"

0
0

hello

I am using the bones template theme but really this question must be so basic that that is irrelevant.

bones has a function for related posts which outputs an <li> foreach post in an array. Above this list I would like to echo a <p> or maybe <h3> tag which just says "here are some related posts"

here is the function

function bones_related_posts() {
	echo '<ul id="bones-related-posts">';
	global $post;
	$tags = wp_get_post_tags( $post->ID );
	if($tags) {
		foreach( $tags as $tag ) {
			$tag_arr .= $tag->slug . ',';
		}
		$args = array(
			'tag' => $tag_arr,
			'numberposts' => 5,
			'post__not_in' => array($post->ID)
		);
		$related_posts = get_posts( $args );
		if($related_posts) {
			foreach ( $related_posts as $post ) : setup_postdata( $post ); ?>
				<li class="related_post"><a class="entry-unrelated" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a><?php the_excerpt(); ?></li>
			<?php endforeach; }
		else { ?>
			<?php echo '<li class="no_related_post">' . __( 'No Related Posts Yet!', 'bonestheme' ) . '</li>'; ?>
		<?php }
	}
	wp_reset_query();
	echo '</ul>';

Of course I don't want this title to show up if there are no related posts, nor do I want it to display foreach related post. ( this, of course, happened when I tried just whacking <p>title related</p> in the if(related_posts) foreach function.

Any help for a rank amateur would be much appreciated. I suppose if I could use the $tag_arr to use the tag name in the title that would be even better but I'd settle for any help or a nudge in the right direction

inspireddev on "Taxonomy only works with permalinks off"

0
0

Hi

I've been building a site for a few weeks now and have had to build a custom taxonomy for Woocommerce product, so as well as categories a product has a collection it can be applied to. I have a custom taxonomy template setup, everything appeared to be working fine.. After leaving the site for a week and a Woocommerce update the Collections taxonomy has stopped functioning. Instead it 301s then redirects to a similar URL. If I disable permnalinks everything works fine. Enable again and it redirects.

So basically this URL -
.../product-collection/pentewan/ (taxonomoy)
Flat out redirects to -
.../interiors/pentewan-collection/ (page)
And its ruining my life.

If I disable the Page that its redirecting too then it will simply 404.

My set up is pretty straight forward, and nothing has changed except a Woo update.

Taxonomy setup code is as follows -


register_taxonomy(
'product_coll',
array('product'),
array(
'label' => __( 'Collections' ),
'hierarchical' => true,
'query_var' => true,
'has_archive' => true/*,
'rewrite' => array(
'slug' => 'product-collection'
)*/
)
);

There was a rewrite rule but I disabled it for testing, still, no affect, and I've cleared the htaccess by toggling permalinks many times... Usual stuff has been done - disabling plugins etc, and because I'm on a temp domain error logs don't appear to be populating, however I can obviously expose errors on the site itself and theres nada issue. The only thing I can relaly find is via Firebug, and thats simply telling me that it is 301ing before it redirects.

Any help or suggestions is greatly appreciated, Its a funny one and I'm not even sure where to start debugging really..

Thanks again for your time - Anthony

VeeBeeGlobal on "Writing Plugin - want to exclude some shortcodes/functions on some pages"

0
0

Hoping someone may know the easiest way to achieve this.

I am writing a plugin for a donations system, and so that I dont load functions and shortcodes I dont need - I want to try and not include them if they are not required.

I have separated the admin functions, and only load these if is_admin.

I have several shortcodes and functions that I want to exclude if not on certain pages of the site. I have these in separate php files which I currently do a require_once with, but the goal is to not load them in some circumstances.

Thanks HEAPS for any help.

V

MindingData on "XMLRPC pingback.ping returning faultCode 0"

0
0

Hi there,

I run a blog that often credits other blogs for content. Instead of putting the "credit" link in the content of the post, I created a custom field for my theme that I then display on the front end below my article.

Because the outgoing link is not in my main content of my post, Wordpress does not pick up that there needs to be a trackback/pingback done. Working forward, I am going to add a hook for post published to try and access this field, but I already have 100's of posts that have not sent out pingbacks. It's not a big deal, but I would like to send those out.

So, I created a PHP script to access the Wordpress DB and pull out everything I needed and ran it in a loop to do a massive ping-athon to all the sites that I haven't pinged yet. Unfortunately I was always getting FaultCode 0 returned, with no message. I'm not the best at PHP, infact I don't know it at all so instead I wrote a console application in C# to ping these from my desktop computer when I provide it a list. But same thing, I get FaultCode 0.

So I tried mucking up the method name. So I sent something similar to this for the data :

<?xml version=1.0?>
<methodCall>
   <methodName>pingback.png</methodName>
   <params>
      <param>
        <value><string>http://mysite.com</string></value>
      </param>
      <param>
        <value><string>http://destinationsite.com</string></value>
      </param>
   </params>
</methodCall>

Notice how I mis-spelled pingback.ping as pingback.png! And I actually got a different error message back about their being no such method. Great! So I am hitting the remote XMLRPC server, but for some reason it's always returning 0.

I saw that the first thing it does when it hits the pingback.ping method, is that it checks if the source URL starts with HTTP or HTTPS (I think, as I say, not the best at PHP). So I sent the source URL as starting with HTP instead of HTTP. And still I got faultCode 0 with no message, so I'm not even sure if it's entering the actual pingback method.

The full "blank" error message I get is below :

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <fault>
    <value>
      <struct>
        <member>
          <name>faultCode</name>
          <value><int>0</int></value>
        </member>
        <member>
          <name>faultString</name>
          <value><string></string></value>
        </member>
      </struct>
    </value>
  </fault>
</methodResponse>

My next step is to write echo statements within the XMLRPC method on my local machine and ping it with junk and see where it's going wrong, but any help would be much appreciated.

albpara on "Sending a form and getting POST data from a custom plugin"

0
0

Hi all,

I am new to WP world and I am starting developing a custom plugin that will show a form and after sending it, the data will be stores on DB but I don't know how to do that...

I'm using the shortcode API so the forms are inserted into posts using something like [form name="my_form"]

What will be the action attribute on the form? I'm using the_permalink() but if the form is sent and with the fields filled, wordpress shows an 404 error...

My code is something like this:

<br />
if ( isset($_POST['send_button_name'] )<br />
{<br />
    print_r( $_POST );<br />
}<br />
else<br />
{<br />
    show_form();<br />
}<br />

If no field is filled, the code works and the post array is displayed but if an input is filled it shows me a 404 error.

Can anyone help me on this?

If this is not the correct way to do this (A plugin that shows a form a stores data on DB) I will be glad to hear other solutions.

Thanks in advance

JustRunLah on "Custom post query but get only posts with IF statement"

0
0

Hello,
I will try to explain my issue here as much as I can, please let me know if it makes sense. I have searched for an answer to this but couldn't get it.

So, I have a custom post type called "race". Every race has custom fields, let's call them "A", "B", "C".

"A" can be an image field, and "B" a checkbox list.

What I want to do is to query and get / list only "races" that have a value on "A". So if "A" is an image, I can show a list of "races that have image". And if "B" can take values "HM", "FM", "5km", I can show only "races which are HM".

I have managed to do that by <?php if( get_field('A'): ?> and if( in_array( 'FM', get_field('race_category') ) or 'FM' == get_field('race_category') ): ?> respectively, the display works BUT, the query still gets all "race" posts, even if it only displays the ones which satisfy the criterion. I know this because of pagination.

For example, I have a total of 16 "race" entries, but only one with "FM" category. As you see at the link, I manage to get it, but it is displayed on the 4th page (current pagination is 5 posts / page, and this is alphabetically the last entry, so pagination works). http://www.justrunlah.com/blog/sg-races-db-full-marathon-events/

Also, I know how to use args arrays for simple stuff, for example I use the following to get entries that are within 2014 only, but I don't know how to implement the more complicated statements needed into the args code.

<?php
		global $paged;
		$curpage = $paged ? $paged : 1;
		$today = date('Ymd');
		$args = array(
		    'post_type' => 'race',
		    'orderby'	=> 'race_date',
		    'meta_key' 	=> 'race_date',
		    'order'	=> 'DES',
		    'posts_per_page' => 50,
		    'paged' => $paged,
		    'meta_query' => array(
		    'relation' => 'AND',
				array(
				'key'		=> 'race_date',
				'compare'	=> '<=',
				'value'		=> 20141231,
			    ),
				array(
				'key'		=> 'race_date',
				'compare'	=> '>=',
				'value'		=> 20140101,
			    )
				),
				);

		?>

In the following PasteBin I am giving you the code that gives that issue: http://pastebin.com/8hwdw0us

Thanks in advance


arun.s on "error on category section"

0
0

getting this error on category selection tab

Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in /home/blog14/public_html/wp-admin/includes/template.php on line 928

please suggest the needful changes to be done to resolve this error

thanks

Kassandra_P on "Change Sort Order of Image Attachment Pages"

0
0

Hi, I'll try to break this down as clearly as possible:

I have several galleries.
The images in each gallery are sorted (alphabetically by last name) according to the image slug.
When you click an image in the gallery, it takes you to the attachment page for that image.
The attachment pages also have navigation so you can cycle through them using previous_image_link / next_image_link

My problem is that the attachment page navigation cycles through the pages in order of date uploaded, rather than by slug like the galleries.

So, how can I sort my image attachment pages by slug?

I'm terrible at php, but I've researched it and it looks like I'll need to create a new WP_Query for attachments. Something like this?

$attachment_navigation = new WP_Query(
array(
    'post_type' => 'attachment',
    'post_parent' => null,
    'post_mime_type' => 'image',
    'post_status' => 'inherit',
    'orderby' => 'slug',
    'order' => 'ASC',
    )
);

From what I've read though, orderby slug doesn't work -- what should I use instead?

And then -- what else? Do I have to write another function to put it into effect? PHP newb here...

Thanks for your help!

MattLeach on "Tags not working"

0
0

I'm hoping someone can help. I have a website for my karate club which has had the theme slightly modified to be more custom. The only problem is that the tags do not work. Everything shows up fine but when you click on a tag at the bottom of an article it goes to a blog page with no articles. I have checked the tag.php file and it looks fine (exactly the same as a fresh install of the theme that works).

Please help. My URL is http://gkrkarateherts.co.uk/news

Any help would be greatly appreciated.

Terence on "Root relative URIs"

0
0

I've always found it frustrating in WordPress that images, files, links, etc. are inserted into WordPress with an absolute URL instead of relative URL. A relative URL is much more convenient for switching domain names, changing between http:// and https:// etc.

Today I discovered that if you define WP_CONTENT_URL with a relative URL then when you insert files into posts they use the relative URL for the src instead of absolute URL. Just what I've always wanted!

But the official WordPress documentation says that you should use a full URI if you are defining WP_CONTENT_URL.

WordPress codex says:

Set WP_CONTENT_URL to the full URI of this directory (no trailing slash), e.g.

define( 'WP_CONTENT_URL', 'http://mydomain.tld/wp-content');

But everything seems to work OK when I use a relative URL, e.g.

define( 'WP_CONTENT_URL', '/wp-content');

Is there some problem with using a relative URI? I’m just thinking that there must be a reason for WordPress stating that it should be defined with a full URI.

Paul on "hide a specific plugin from Registered users or subscribers."

0
0

can any tell me how do I hide a specific plugin from Registered users or subscribers. I want it to run only for the guest users. One more help ,how to load the plugin only in first page view in a session. Even the answer for my first question will help me a lot.

I wanted the answer w.r.t plugin "Automatic Social Locker"

below is some more helps required on the same plugin. if it is possible.

1. To disable popup for registered users or subscribers
2. Freeze ESC key, since ESC key closes the popup layer
3. SHow the pop up only one time in a session.

https://wordpress.org/plugins/automatic-social-locker/

thanks in advance.

Viewing all 8245 articles
Browse latest View live


Latest Images