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

Satyapriya on "How to add tags to identify custom post types in archives?"

$
0
0

The most important thing I would like to add that is missing from my site is colored post type tags for each of my 7 custom post types within the category archives, search archives, and tag archives (which all use the same template file). I was able to manually add colored post type tags to each of the 7 single.php files by adding the following code (this one is for single-articles.php):

<div class="post-type-articles-container pull-left"><a href="http://collectivelyconscious.net/articles">Articles</a></div>;

I think that what I need for the archive template is for the 7 codes for each post type to be there within the loop, but it needs to be conditional or something depending on which post type is being called. I just don't know what the PHP code is that I need to use to do this. Here is what I have added to the archive template in order to get the custom taxonomies for each custom post type to work:

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'articles-archives', ' ', '<br />' ); ?></div>

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'questions-archives', ' ', '<br />' ); ?></div>

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'videos-archives', ' ', '<br />' ); ?></div>

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'documentaries-archives', ' ', '<br />' ); ?></div> 

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'ted-talks-archives', ' ', '<br />' ); ?></div>

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'memes-archives', ' ', '<br />' ); ?></div>

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'music-archives', ' ', '<br />' ); ?></div>

And here is the code for the tags that appears just after it:

<div class="pull-left"><?php the_tags('<div class="post-tags">', ' ', '</div>'); ?></div>

So I'm assuming I would need to add similar PHP code as what is used for the taxonomy terms, but I just don't know what it is... Does anyone know?


kshilpa1385 on "WordPress Login credentials Pass to another site"

$
0
0

[Moved from Your WordPress which is NOT a support forum.]

hi,

I have 2 websites one is in wordpress and another is in asp.net.

I want pass login credentials of wordpress to asp.net

So please tell me how should do it?

I am new in wordpress, so please help me.

Aniela on "How to activate this function?"

$
0
0

Hello,

i have a plugin and want to activate this function:
// href=" echo get_ permalink(get_option('jigoshop_myaccount_page_id')); ">Log in to Add to Wish List

It doesnt appear on my page yet, but I want it to disply "Log in to Add to Wish List", but I dont know how to. This is the whole code snippet where this part is embedded:

function jwl_addToWishListButton( $post, $_product ){
	global $user_ID, $jwlOptions;

	if( $user_ID ){
		$list = new jwl_wishlist( $user_ID , 'user_id', false );
	?>
	<form method="POST" action="" class="jwl-wishlist" >
		<input type="hidden" name="jwl_product_id" value="<?php echo $post->ID; ?>" />
		<input type="hidden" name="jwl_user_id" value="<?php echo $user_ID; ?>" />
		<input type="hidden" name="jwl_list_id" value="<?php echo $list->id ; ?> " />		

		<!-- Nonce -->
		<?php wp_nonce_field( 'add-remove-wishlist-item', 'jwl_addremove_nonce', false); ?>

		<?php if( !$list->item_exists( $post->ID ) ): ?>
		<input type="submit" name="jwl_addToWishList" class="<?php echo $jwlOptions->op( 'add-to-cart-class' ); ?>" value="<?php _e( $jwlOptions->op( 'add-to-wishlist-button-text' ) , 'jigowishlist' ); ?>" />
		<?php elseif( $jwlOptions->op( 'show-remove-button' ) ): ?>
		<input type="submit" name="jwl_removeFromWishList" class="<?php echo $jwlOptions->op( 'add-to-cart-class' ); ?>" value="<?php _e( $jwlOptions->op( 'remove-from-wishlist-button-text' ) , 'jigowishlist' ); ?>" />
		<?php endif; ?>
		</form>
	<?php
	}
	//  href=" echo get_ permalink(get_option('jigoshop_myaccount_page_id')); ">Log in to Add to Wish List

}

If anybody has an idea what to change or add I'd be so happy. Thank you!

[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.]

Lydia on "Image Map"

$
0
0

Hello!

I recently set up my first Wordpress blog (www.planetlydia.com), and I have a graphic that I'd like to use in my sidebar to link to my pages. I've been trying to make it into an image map, but I couldn't get it to work. I finally realized it was probably due to my theme being responsive, so I installed a plugin called "Responsive Image Maps". The image is now appearing with all the proper links, but I'm having a strange issue with the links . . .

When I click on the box that should lead to my page, it does pull up the link for that page. However, somehow the original link doesn't get cleared out, so the second link builds on top of it. For example: I start at "www.planetlydia.com" and click on the graphic for my archives page, and the url becomes "www.planetlydia.com/www.planetlydia.com/archives/, which of course leads to a 404 Not Found. I hope that makes sense . . . you can visit my blog and see for yourself. Just click on a page, and try to navigate to a new page.

I don't think it's an issue with Wordpress or the plugin, because I tried pasting the code into an old blogspot blog and had the same issue. It must be the code, and I feel like I must be missing something super simple. The code for the image map is listed below:

'<img src="http://planetlydia.com/wp-content/uploads/2014/02/PL_Pages.jpg" usemap="#mo10958" width="300" height="520" alt="click map" border="0" />
<map id="mo10958" name="mo10958">
<area shape="rect" alt="About" coords="1,395,299,432" href="www.planetlydia.com/about/" target="_self" />
<area shape="rect" alt="Archives" coords="1,434,299,474" href="www.planetlydia.com/archives/" target="_self" />
<area shape="rect" alt="Etc." coords="1,476,299,512" href="www.planetlydia.com/etc/" target="_self" />
<area shape="rect" alt="Home" coords="1,1,298,394" href="www.planetlydia.com" target="_self" />
<area shape="default" nohref alt="" />
</map>'

acasmi on "Get recent comments from a specific array of users?"

$
0
0

Hi, I am trying to display a list of recent comments from several specific users (in my case user ids 14,56,58,200) who form a team. On their team page I simply want to list their recent comments.

I feel like I'm nearly there, as on each team members individual page I run a query that displays that one team members comments, using this code:

<?php
    $args = array(
        'user_id' => 200,  // TEAM MEMBER
        'number' => 3, // how many comments to retrieve
        'status' => 'approve'
        );

    $comments = get_comments( $args );

    if ( $comments )
    {
        $output.= "<ul class=lastcomments>\n";
        foreach ( $comments as $c )
        {
        $output.= '<li><p>';
	$output.= get_comment_excerpt($c->comment_ID);
	$output.= '</br><span>Posted in: <a href="'.get_comment_link( $c->comment_ID ).'">';
        $output.= get_the_title($c->comment_post_ID);
        $output.= '</a>';
		$output.= ' on '. mysql2date('m/d/Y', $c->comment_date, $translate);
        $output.= "</span></p></li>\n";
        }
        $output.= '</ul>';

        echo $output;
    } else { echo "No comments made";}?>

All attempts to display multiple users comments, however (using an array for user_id for example) have failed so far. The formatting of the list needs to be the same, just with 5 specified users instead of 1.

I have hit a coding wall. Any help would be greatly appreciated!

djp1900 on "How to take user input from custom fields and insert them into a post?"

$
0
0

It's hard to explain exactly what I am trying to do, and it's easier if you look at the site itself (emailreport dot net). I am running the Golpik theme on 3.8.1.

I need to take info entered by the user and turn that into a post. I have been able to create posts with the Gravity Forms plugin that takes the email address entered (on the submit email report page) and turn that into the post title and the description becomes the body of the post, but I can't figure out to get the name, location and ip address custom fields from the form to show up in the post.

Any suggestions on what I can do?

Cibulka on "post_tags_meta_box() - Javascript functionality no longer works"

$
0
0

Hello all!

As my custom taxonomies are essential for my articles, I would like to move them from side menu to my custom meta box.

Here is (simplified) code I'm using:

// Remove taxonomy meta_boxes from side
function tax_remove_from_side() {
    remove_meta_box('tagsdiv-skill', 'web', 'side' );
}
add_action('my_custom_hook', 'tax_remove_from_side');

// Add taxonomy meta_boxes to my custom meta_box
function tax_add_to_box() {
	global $post;
	$tax = get_object_taxonomies(get_post_type());
	echo '<div id="meta_tax">';
	foreach ($tax as $t) {
		$t_o = get_taxonomy($t); ?>
		<div class="cell item">';
			<strong><?php echo $t_o->labels->name; ?></strong>
			<?php if ($t_o->hierarchical) {
				post_categories_meta_box($post, array('args' => array('taxonomy' => $t), 'title' => $t_o->labels->name));
			} else {
				post_tags_meta_box($post, array('args' => array('taxonomy' => $t), 'title' => $t_o->labels->name));
			} ?>
		</div>
	}
	echo '</div>';
}
add_action('my_custom_hook_for_metabox', 'tax_add_to_box');

Does that make sense?

My problem: If I remove all nonhierarchical taxonomies from sidemenu, link "Choose from the most used tags" and other JS functionality for nonhierarchical (tag-like)taxonomies stops working. Oddly enough, hierarchical taxonomies (category-like) JS functionality works smoothly.

My current ugly solution: Custom taxonomy called "Very nasty hack" that is left on sidebar (so JS functionality remains) but is never included to my custom meta_box. :) Very nasty, but works.

///

After some digging in core files, I think I've found relevant pieces of code for the problem: file wp-includes/js/post.js, lines 19-179. Especially variable Disabled, defined under function quickClicks on line 58.

I see, that the variable works in a few conditionals later, but to be honest, that is as far as my understanding of the situation goes. :)

///

Any idea how to enable JS functionality for nonhierarchical meta_boxes even if they don't appear at the side menu PROPERLY? THANKS IN ADVANCE!

benvolio on "Wordpress Adminbar - wp-admin-bar-top-secondary"

$
0
0

I was just wondering how i could put the wp-admin-bar-top-secondary (account section of wp-adminbar) in my site header via header.php; is there any kind of php function to summon this in my header.php file; could who ever knows how to do this kindly assist me with this tiny issue. Thanks in advance :)

*oh, and am using a local server to test my site.


olddocks on "$content_width ??"

$
0
0

What exactly does this do? it seems all themes require to set this variable like this

if ( ! isset( $content_width ) )
	$content_width = 600;

I am creating a theme, where in the options panel, people can disable sidebar. If the sidebar is off, the theme shows posts and pages full width (1000px) else 700px with sidebar.

How do i set $content_width accordingly to this?

hannahhayes on "Removing year from archive list"

$
0
0

Hi there,

Is it possible to get the archives list to display the month only? For example, January as opposed to January 2014.

I'm trying to create an archives intro that is tabbed by year:

http://www.everly.co.uk/2009/12/

But I'm not very good with code outside out HTML and CSS and I can't figure it out!

Thanks.

Paul Skip Brown on "Get canonical link"

$
0
0

Hi I know get_permalink returns the URL. Some of my posts are redirected and at the same time I update the canonical link to the redirected post URL - (normally relates to post updates).

Is there a function I can use to return the canonical URL of a post if it has one rather than it's 'permalink' URL? I use Yoast SEO to edit canonical URLs and also apply redirects.

exedesign2 on "Facebook user login integration with WordPress"

$
0
0

I am trying to use Facebook login to register users to my blog, but after users logged in their Facebook account, their account is still not created on my WordPress. Could anyone take a look and advise please. I would like to have the users been registered by taking their Facebook email and creating a random password. After he registered and automatically logged in, I plan to send the user to his account where he can update the name, add few custom user meta data, and add a short bio. The codes for the Facebook login integration with WordPress I'am using are bellow:

1- // This is the login button that goes in my index/page

<a id="FbConnect" class="join-facebook" href="#">Rejoignez-nous sur facebook</a>
2- // This goes in my functions.php

`//create facebook href button
function FbC_head(){
if( is_user_logged_in()) return;
?>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID', //have already registered the facebook app, so that's not an issue
status : true,
cookie : true
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<?php
}
add_action( 'wp_head', 'FbC_head' );//end

//load jquery if needed
function FbC_enqueue_scripts(){
wp_enqueue_script( 'jquery' );
}
//add_action( 'wp_enqueue_scripts', 'FbC_enqueue_scripts');//end

//event handler in footer
function FbC_footer(){
?>
<script>
$('#fbLogin').click(function() {
FB.getLoginStatus(function(response){
if(response.status !== 'connected') {
//console.log(response.authResponse);
FB.login(function(fbresponse) {
//console.log(response.authResponse);
if(fbresponse.status=="connected") {
response = fbresponse;
$('#fbLogin').click();
}
}, {scope: 'email'});
}
if(!response.authResponse) {
return;
}
FB.api('/me', function(resp) {
var data = {
authResp : response.authResponse,
userResp : resp
};
//console.log(data);
jQuery.ajax({
method : 'GET',
url : '<?php echo dirname( get_bloginfo('stylesheet_url') ) ?>/checkFB.php?callback=?',
data : data,
dataType : 'jsonp',
jsonpCallback : 'reply',
contentType : 'application/json',
success : function(resp) {
//console.log(resp);
if(resp.status == "Success")
window.location.reload();
else
console.log(resp.errors);
},
error : function(e) {
console.log(e);
}
});
});
});
});
</script>
<?php
}
add_action( 'wp_footer', 'FbC_footer' );//end`
3- // Finally this is the function supposed to do the registration and it name according to 1- (checkFB.php)

`//don't worry I don't wanna show this on http://wordpress.stackexchange.com/!
require_once('/this_is_the_path_to_my_server_/wp-load.php');
require_once('/this_is_the_path_to_my_server_/wp-config.php');

/*
$_REQUEST is sent with 2 arrays. We will retrieve the ID and then start checking.
*/
$login = $_REQUEST['userResp']['id'];

//Check if the username exists already
$id = username_exists($login);
$errors = array();

//Case 1 : When the ID doesn't exist.
if(!$id) {
$email = $_REQUEST['userResp']['email'];
$existingID = email_exists($email);
//Case 1 confirmed : If the email also does not exist, we can proceed with registration.
if(!$existingID) {
$pass = wp_generate_password( $length=12, $include_standard_special_chars=false );
$userData = array();
$userData['user_login'] = $login;
$userData['user_email'] = $email;
$userData['user_password'] = $pass;
$userData['user_nicename'] = $_REQUEST['userResp']['first_name'] .' '. $_REQUEST['userResp']['last_name'];
$userData['first_name'] = $_REQUEST['userResp']['first_name'];
$userData['last_name'] = $_REQUEST['userResp']['last_name'];
$insertStatus = wp_insert_user($userData);
if(is_wp_error($insertStatus)) {
$errors = array_merge($errors, $insertStatus->getErrorMessages());
}
else {
wp_set_auth_cookie($insertStatus, true);
}

}
//Case 2 : When the email ID the user has attached to his FB account is also registered here.
else{
$userFB = get_user_meta($existingID, 'fbid', true);
//if a user is already attached to the email.
if(!empty($userFB)) {
//Case 2a : Here we match the Facebook ID of the user to the facebook ID of the email ID.
if($userFB == $login)
wp_set_auth_cookie($existingID, true);
else {
array_push($errors, __("Another Facebook ID seems to be attached to your account. Please check."));
}
}
//Create the link between the user's email ID and the facebook ID for the first time, and log him in.
else {
if(!add_user_meta($existingID, 'fbid', $login, true)) {
array_push($errors, __("Sorry! We were unable to link your FB account."));
}
else {
wp_set_auth_cookie($existingID, true);
}
}
}
}

//Case 3 : When the user is already registered
else {
wp_set_auth_cookie($id, true);
}

$resp = array();
if(!count($errors)) {
$resp['status'] = "Success";
$resp['loggedIn'] = true;
$resp['errors'] = $errors;
}
else {
$resp['status'] = "Failure";
$resp['loggedIn'] = false;
$resp['errors'] = $errors;
}
echo "reply(".json_encode($resp).")";`
I am not trying to use any plugin out there because they are overcomplicated. I don't want to have to deal with any setting. I just wanna be able to set the Facebook login option and forget about it. Thanks for helping.

Cibulka on "Get current post_type from wp_loaded hook"

$
0
0

Hello again!

Is it possible to get current post type from (pretty early) wp_loaded hook? Get_current_screen() or global variable $typenow are apparently not ready by that time.

The only thing I was able to google out was getting the post type by $_GET method which doesn't really work in my case (as I don't see the post_type in my URL).

Thanks!

anjanphukan on "How to order posts by comment count and then by published date?"

$
0
0

Hi
How can I order posts by comment count and then by published date? So that it will show the highest commented post first and for equal number of commented posts, it will show the recent post first.

Please help.

sjbmaine on "CSS Styling Based on Grandparent Page? How to?"

$
0
0

I am using the following styling to pull in a custom banner for my pages. This works well for the top page and the child page. However, I've added a grandchild page. How would I modify the CSS to style the banner for the grandchild?

.page-id-9 #banner, .parent-pageid-9 #banner  {
	background: #15375e url('images/broadband.png') no-repeat left;

Osu on "Disabling wp-login.php register form"

$
0
0

Hi,

I've been getting a few spam sign ups lately and trying to think about the best way to disable them while still allowing sign ups via a plugin I'm using called 'Profile Builder Pro'.

Is there a way to use functions.php to literally not return the register form here? http://www.domain.com/wp-login.php?action=register

That would mean people could only sign up via the front end with the plugin.

Anyway tips really apprecaited.

Thanks,

Osu

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.

josh5723 on "Custom Header (Text, Not Image) Per Page?"

$
0
0

I am working with a site for a local business which has multiple locations. We're using a premium theme which has a custom option to input our phone number into the header. The issue is we want a different phone number for certain pages. If I leave the custom theme option for the phone number blank, it'll show up blank on the site.

I know very little about coding, so I'm hoping this is easily doable. Is there a way to create 2 separate header.php files and tell certain pages to draw from say, header2.php (which would have the different phone number hard coded into it) ?

Or any other solutions/plugins?

Thanks!

fyreus on "WP Custom Menu Problem Solves"

$
0
0

There are many posts/responses and such on this topic and not many work-arounds or fixes (many topics closed) so this will addresses this glaring issue many of us have with Wordpress not making new menus, provided the theme supports 2+ menus at once.

-Open .htaccess and add this to your first line:
"php_value max_input_vars 2000"
-Delete your menus and create a new one
-Copy the URL during the 'Create Menu'
-Make your menu
-Save the menu
-Paste the previous URL into the URL
-Change the number on the end:

(ex: http://mysiteDOTcom/wp-admin/nav-menus.php?action=edit&menu=7 When you create a new menu and save it, there will be a positive number like 3, 6, or even 7)

-After changing the LAST digit/number, and hitting enter in the url, set up a SECOND menu and save it with a different name.
-Go to Menu Locations and set your new menus.
-Save changes.
-Pat yourself on the back :)

DennisSnijder on "Google Webmaster tools search rss feed on sub folder"

$
0
0

hello wordpress forums

my google webmaster tools search my rss feed in my subfolder where wordpress is stored , but i want that it search on the root
right now it search http://domain.com/wp/rss
but i want it like http://domain.com/rss

where should i change this?

Viewing all 8245 articles
Browse latest View live




Latest Images