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

hanhaoran on "Ignore sticky posts' sticky status (but keep design)"

0
0

hi guys, this may sound highly unusual, but I am looking for a way to ignore the sticky status of sticky posts, if possible site wide.

background: i am working with a really nice theme and love how it highlights sticky posts (in terms of design). I need to apply this highlighted design to one category of posts (which will be members only content), but the theme unfortunately doesn't make full use of post_class, so i can't style the category based on the class.

if i find a way to ignore the sticky status for posts marked sticky, that would solve my problem though, i would simply mark all member content sticky, they would be highlighted accordingly, but they would still be sorted in with the rest of the posts based on publication date.

So far I only found a way to globally switch off stickiness altogether, but that results in the sticky attributes also not being saved, so the styling is not applied either...

thanks for any hints here!


ADKSherpa on "Dont allow users to edit "Name""

0
0

Im looking for a way to set my website up so that only administrators can edit anything under "Name" for users (that includes, Username, First Name, Last Name, Nickname, and Display name publicly as).

Ideally those fields would just be grayed out for non-administrators.

Any thoughts?

patsfans on "Eliminating "Pages: " Prefix on pagination"

0
0

I'm trying to set up pagination buttons when I break up my posts with the <!--nextpage--> tag that say "CONTINUE" and "PREVIOUS", and am trying to eliminate the "Pages: " prefix that appears in front of them. Does anyone happen to know what template that's in so I can remove it?

Ian

edow on "Category sidebar seach: checkbox and custom fields problem"

0
0

Hi,

I'm struggling with the following problem for a while. It's almost working, but still not yet. First of all, sorry for my bad English.

I made this sidebar search form (see code below) for my category page to filter the search results based on the tags which are available within the category.

The first part is working great when I use radio buttons, but I want the form to remember mulitple checkbox fields. Someone suggested name="tag[]" but that's not working unfortunately. When I use name="tag" the url output is /?tag=test&tag=test2 instead of /?tag=test,test2 so it won't work properly.

The next problem. I use this function to make a url parameter based on a custom field, but I can't figure out how to use it with multiple keys.

function wpa_filter_home_query( $query ){
    if( $query->is_main_query()
    && isset( $_GET['provincie'] ) ) {
        $meta_query = array(
            array(
                'key' => 'provincie',
                'value' => array( $_GET['provincie'])
            )
        );
        $query->set( 'meta_query', $meta_query );
    }
}
add_action( 'pre_get_posts', 'wpa_filter_home_query' );

And the last problem is that I want to show only keys from custom fields under <h3>Land</h3> and <h3>Regio</h3> just like the code only shows tags which are used. I also can't figure out how to let this work for the custom fields.

The form:

<form name="tags" onChange="document.forms.tags.submit();">
		<?php
		if (is_category()){
		  $cat = get_query_var('cat');
		  $yourcat = get_category ($cat);
		}
		$tag_IDs = array();
		query_posts('category_name='.$yourcat->slug);
		if (have_posts()) : while (have_posts()) : the_post();
		  $posttags = get_the_tags();
		  if ($posttags):
			foreach($posttags as $tag) {
			if (!in_array($tag->term_id , $tag_IDs)):
			   $tag_IDs[] = $tag->term_id;
			   $tag_names[$tag->term_id] = $tag->name;
			   $tag_slug[$tag->term_id] = $tag->slug;
			 endif;
			}
		  endif;
		endwhile; endif;
		wp_reset_query();

		if (!empty($tag_IDs)){
			echo '<h3>Het meest geschikt voor</h3>';
			echo "<input type=\"checkbox\" name=\"tag\" value=\"\"> Show all<br>";
		}
		foreach($tag_IDs as $tag_ID){
			$checked = $tag_slug[$tag_ID];
			echo '<input type="checkbox" name="tag" value="'.$checked.'"' ;
			if((isset($_GET["tag"])) && $_GET["tag"] == $checked) {
			echo ' checked="checked"';
			}
			echo '> '.$tag_names[$tag_ID].'<br>';
		}
		?>

		<div class="margin25px"></div>

		<h3>Land</h3>
			<input type="radio" name="land" value=""> Alles weergeven<br>
			<input type="radio" name="land" value="nederland" <?php if((isset($_GET["land"])) && $_GET["land"] == "nederland") { echo "checked";}?>> Nederland<br>
			<input type="radio" name="land" value="belgie" <?php if((isset($_GET["land"])) && $_GET["land"] == "belgie") { echo "checked";}?>> Belgie

		<div class="margin25px"></div>

		<h3>Regio</h3>
			<input type="radio" name="provincie" value=""> Alles weergeven<br>
			<input type="radio" name="provincie" value="gelderland" <?php if((isset($_GET["provincie"])) && $_GET["provincie"] == "gelderland") { echo "checked";}?>> Gelderland<br>
			<input type="radio" name="provincie" value="overijssel" <?php if((isset($_GET["provincie"])) && $_GET["provincie"] == "overijssel") { echo "checked";}?>> Overijssel
		</form>

Hopefully someone can give me some hints to make this work. It's a great category search form if it's working properly. Sorry if I ask to many questions, but it's all related to each other since it's all meant to make the sidebar filter function work.

WilliamKF on "How to unlock user?"

0
0

I only have one user and they are now locked out:

You have been locked out due to too many login attempts.

How can I edit MySQL database to unlock the one and only user?

stansglover on "My wp admin has been hacked. L. Help"

0
0

My website wp admin has been hacked how do I get rid

Simcams-concepts.co.uk/wp-admin

Call_Me_Matthew on "How to assign a Page Template to certain URL Patterns?"

0
0

Is there a way to set up a page template that assigns itself to pages of a particular url structure?

For example, say you have these urls:

http://www.mysite.com/beachhouse/snippet
http://www.mysite.com/hospital/snippet
http://www.mysite.com/farm/snippet
http://www.mysite.com/mansion/snippet

I don't want to have to create pages manually for every "snippet' subpage on my site. Instead, I want to create a page template that will load automatically when a url with a pattern of "http://mysite.com/x/snippet" is visited.

I've already created a template file that loads content dynamically depending on the parent page(it takes the parent's slug from the url and serves up content based on that). I just need help figuring out how to assign it to a specific url pattern, as opposed to a page.

Thanks for any help!

solutionica on "Publish button hook"

0
0

i want to share post on facebook when a new post is published, but can't find hook for it to do so when published button is clicked. any help will be appreciated.

thanks


Luke Janicke on "Category ID/slug from wp_get_nav_menu_items"

0
0

I’m writing a custom "custom menu" function. The menu items are (mostly) categories. I want to add the category slug as a class to the li elements.

function news_custom_menu( $location ) {

	// Custom Menu

	if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $location ] ) ) {
		printf( '<ul class="%s">' . "\n", $location );
		$items = wp_get_nav_menu_items( $locations[ $location ] );
		foreach ( (array) $items as $key => $item ) {
			$title = $item->title;
			$url = $item->url;
			$ID = $item->ID;
			$category = get_category( $ID );
			$slug = $category->slug;
			printf ( '<li class="%s"><a href="%s">%s</a></li>' . "\n", $slug, $url, $title );
		}
		echo '</ul>';
	}

$title and $url work. However, either $ID is not the category ID or I’m doing something wrong with get_category().

Which item in the returned object ($item) is the category ID?

Reference:
http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items

dilipcom2010 on "Does using get_posts() to fetch all the post data affect the host site?"

0
0

I'm making a plugin which extracts all the data from wordpress blog when the user activates the plugin and hits my database api. The code I'm using is as under:

$allposts=get_posts($args);
			echo "TotalLength: ".sizeof($allposts).";";
			if($allposts)
			{
				$str=array();
				$cnt=0;
				$cnt1=0;
				foreach($allposts as $post)
				{
					$cnt = $cnt + 1;
					array_push($str,post_detail($post));
					if($cnt == 10)
					{
						//echo "Count ".$cnt1." = ".$cnt;
						$cnt1 = $cnt1 + 1;	

						$cnt =0 ;
						$str =array();
					}
				}
				if($cnt>0)
				{
					//echo "Count ".$cnt1." = ".$cnt;
					$jsonl = json_encode($str);
					echo'<script type="text/javascript">hit_pd_server('.$jsonl.');</script>';
				}
			}

I checked other related post plugin and found some of them using this method. However, my concern is if a blog contains tens of thousands of posts, would using get_posts() affect their site. I can handle the traffic on my api but I'm not sure if their blog can handle the requests made by get_posts().
Also, what are the alternatives to get_posts() that can ensure that I fetch the data from client's site one by one or be able to fetch them in batches instead of fetching all of them once.
Any best practices on making related post type plugins that you can share will also be appreciated ?

xymalf on "creating a skeleton plugin framework."

0
0

I would like to create an menu for a plugin I am developing. So far I have followed examples in books but have got nothing to work. I just want a simple tag on the wordpress dashboard with Settings and Application below it - can anybody point me in the right direction.

xymalf on "How do I modify this options plugin please?"

0
0

[ Code redacted. For that many lines of code please use pastebin.com instead. ]

Dogberry on "Suspicious 'Administrator'"

0
0

The last freelance developer I hired to do a small job on my site (http://beyond-freedom.com) did something very fishy. I have been advised to uninstall and reinstall WordPress. I’m traveling abroad and plan to do just that when I’m back to the U.S. July 6th. Meanwhile, can someone advise me about how I can get rid of a suspicious User entry, listed as a second Administrator besides me. The entry is listed on Users’ page as follows:

Under Username, I see Username; under Name there’s Name; and under Role is listed Role.

Thanks,

Tafader

AvWijk on "[Audio Embeds] Automatically create download link?"

0
0

I'm maintaining the website of a choir and I use the Insert Media functionallity to insert MP3 audio to a post.

As you al know that looks something like this: [audio mp3="http://www.somesite.com/wp-content/uploads/2014/06/FIELDS-OF-GOLD-S1.mp3"][/audio]

Unfortunately it's not possible from the front-end to download the track, only to play it. It's a closed off members-only website and members should be able to download own recorded material, so that covers the whole legal thing.

Is there any way in functions.php to change this

[audio mp3="http://www.somesite.com/wp-content/uploads/2014/06/FIELDS-OF-GOLD-S1.mp3"][/audio]

to this, in an automated way?

[audio mp3="http://www.somesite.com/wp-content/uploads/2014/06/FIELDS-OF-GOLD-S1.mp3"][/audio]
<a href="http://www.somesite.com/wp-content/uploads/2014/06/FIELDS-OF-GOLD-S1.mp3">Download FIELDS-OF-GOLD-S1.MP3</a>

armaniworld on "create wordpress plugin to override theme file"

0
0

Hi i am trying to create a wordpress plugin that will replace a file in my theme called theme-searchbar.php

when activated the plugin will use the theme-searchbar.php in the plugin folder and not the themes.

can anyone help or point me in the right direction?

cheers.


Rod Roark on "How to test upgrading before publising the new version?"

0
0

Dumb question here from a new plugin maintainer. I want to test the upgrading of my plugin to a new release -- without deactivating or deleting the prior installation. For obvious reasons it would be good to test this before publishing the new release. How is that done?

presley.cobb on "Last modified date"

0
0

Im trying to get the last modified date to appear on my pages. The problem is I want to display the last modified date of a different page. So say I have my homepage index.html I want to be able to display in the sidebar a list of pages and next to them the last modified date of those pages. How do I store and retrieve those values so I can display them. Im in the process of learning php so bare with me if im a little slow on the uptake.

THANKS!

ziel100 on "Qtranslate"

0
0

hi i use the latest version from qtranslate and qtranslate slug. and i had big problem a many 404!!! my languages are french englisch and german
and the slug / post are showing so" http://xkclassic.com/jaguar-xk-120/jaguar-xk-120-technische-details" this is the english version but german also i get a 404 the same in french! I want to make a redirect(with htacces or with redirect plugin) but i must give the redirect without xkclassic.com and so i redirect the whole url this is not what i want. this url must show to http://xkclassic.com/de/jaguar-xk-120/jaguar-xk-120-technische-details. have anybody an idea what i can do? sorry for my english i'm from germany

edow on "Remove text field from comment form"

0
0

Hi,

I would like to remove the text field from the comment form. The idea is that users can vote if they like the post or not. The like/unlike option must be done with radio buttons in a custom field (that would be the next problem).

But first: How can I remove the text field? I don't want it hidden, but entirely removed. What is the best practice for this? I can't find a decent solution.

Hopefully anyone can help me with this.

edow on "How to show the posts with the highest votes on homepage"

0
0

Hi,

I use this code to show the post score which bcworkz made for me:

<?php
$counts = aigoo_get_score();
extract( $counts );  //restores compacted variables

<span>+'.$score.'</span>
?>

This is in my functions.php:

<?php
/* Display likes/unlikes */
function aigoo_get_score() {
   $comments = get_comments( array('post_id' => get_the_ID(),) );
			$likes = array();
			$unlikes = array();
			foreach( $comments as $comment ) {
				if('unlike' == $comment->comment_content ) $unlikes[] = $comment;
					else $likes[] = $comment;
			}
    $likescore = count( $likes );
	$unlikescore = count( $unlikes );
	$score = count($likes) - count($unlikes);
	$totalvotes = count($likes) + count($unlikes);
	return compact('likes', 'unlikes', 'likescore', 'unlikescore', 'score', 'totalvotes');
}
?>

Now comes the new part of code I just use. The following code is showing the latest 5 posts with the most comments in a specific category on my homepage:

<?php
			$popular = new WP_Query( array(
				'post_type'             => array( 'post' ),
				'showposts'             => 5,
				'cat'                   => 'activiteit',
				'ignore_sticky_posts'   => true,
				'orderby'               => 'comment_count',
				'order'                 => 'dsc',
				'date_query' => array(
					array(
						'after' => '0',
					),
				),
			) );
		?>
		<?php while ( $popular->have_posts() ): $popular->the_post(); ?>
			<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a> (<?php comments_number( 'Nu stemmen!', '1', '%' ); ?>)</li>
		<?php endwhile; ?>

How can I make it happen that instead of showing the posts with the most comments it shows the posts with the highest voted comments on my homepage? (See the first and second code.)

I don't know if it's even possible. Hopefully someone can help me with this.

Problem 2:
I also notice that when I duplicate this code and change the categoryname it lists both only one category even when the category name is different.

Viewing all 8245 articles
Browse latest View live




Latest Images