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

Zilli on "Post Types with custom Rewrite Slug give 404"

$
0
0

Hi. The following code https://gist.github.com/chrismccoy/8825664 will produce a url like:
domain.com/videos/funny/cute-dogs/

What I need is:
domain.com/funny/cute-dogs/

So, I thought that if I just remove the videos/ part from the CPT rewrite slug, it would works. But it doesn't. Once I remove the videos/ form the slug, everything goes 404. What do i do?


NovaSev on "Filters....I think..."

$
0
0

So I'm using the wp_login_form(). All of it's working swell but...

Here's my issue - I want to change the class that is automatically populated with it's submit button. I've done so by just changing the class in the wp-includes/general-template.php but I'm sure that gets written over again once I have to update wordpress. Can I do a filter for this? Is there a good link that you can provide that will show me how to create a filter for this and possibly other things as well?

I'm a bit new to php so this may be really simple .... thanks for the help.

Lavelight on "[plugin write]Static function error"

$
0
0

Hi everyone :)

I writing plugin and i have some problems.
Working on localhost - xampp and here check my plugin.
Plugin works have 100% correct on my localhost.
Problem started when i transfer file on real host

Website error

Parse error: syntax error, unexpected T_STATIC in

This is line:

if(get_current_screen()->id == 'toplevel_page_'.static::$plugin_id){

up script

class blabla{
private static $plugin_id = 'blablabla';

Host use php 5.4.21

johnbeardy on "Custom post types, slugs, single-post-type template"

$
0
0

I've a custom post type which is displayed through a single-post-type file.

I don't want to display the slug in the URL, and this VIP WordPress hack almost works. "Almost" is because it removes the slug and doesn't break general post/page permalinks, but the custom posts are now displaying as blank, as if single-post-type is no longer being called.

How can I get the slug-less page to call the single-post-type?

difimon on "Include and use PHP class into a wordpress page"

$
0
0

Dear all,

I have a class in PHP named sample.class.php which I want to include in a wordpress page to exploit its functions. I am using the template twentytwelve and I have installed the plugin exec PHP to write php code into wp pages. I tried to do this until now with bad results:

- I've created a folder called "includes" into this path wordpress/wp-content/twentytwelve and then:

- I've tried to do this in a wordpress page (but doesn't work)

<?php require_once('includes/sample.class.php');

and its error is the following:

Parse error: syntax error, unexpected ‘<’ in /Applications/XAMPP/xamppfiles/htdocs/wordpress/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()’d code on line 11

...and also this:

include(get_bloginfo('twentytwelve').'/wp-content/twentytwelve/sample.class.php');

Anything works here. Can you explain me what I have to do in order to solve this mistake?

Thank you in advance.
Marco

Manoj Trivand on "How to sort the posts using their post_type"

$
0
0

I am using two custom post_types where i display both of them in the search page. There i need to sort the posts according to their posttype.

like if(custom_post_type1)
{
print all posts under custom_post_type1;
}elseif(custom_post_type2)
{
print all posts under custom_post_type2;
}

I can see that there is query_post , i am not sure about the arguments, specifically i need the post types 1 to be at the first and the other after these posts.

madsrh123 on "Taxonomy and post types"

$
0
0

I know that there's a ton of threads on this topic, but I can't find any help on this specific issue.

Let say I have a movie review site and want to be able to select a film production company for each movie inside my post-type.
I could do this with taxonomy but then I can't add/edit company logo, description, etc.

I guess I looking for a post-type inside a post-type or ....?

Can any on help me or perhaps point to a tutorial?

//MadsRH

everyeurocounts on "Add terms to taxonomy"

$
0
0

Hi,

I am writing a plugin using OOP.

I have a class (activated from the main plugin file by require_once) to create a custom post type and a hierarchal taxonomy and to populate the taxonomy with parent and children terms. The code below works as in the parents (carmakes) are added but when i try to add the children, only the 1st is added. On the taxonomy screen there are 4 pages now visible but they are blank. The database has the children added with the correct parent id......Anyone able to shed some light on this?

class car_post_type {
	var $dname= 'carmarket';
	var $makes= null;
	var $taxonomy = 'carmake';

	public function __construct () {

	$car= new base_posttype ('carmarket', array(
	'has_archive' => TRUE,
			'menu_position' => 11,
			'rewrite' => array(
				'slug' => $dname,
				'with_front' => FALSE,
			),
			'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'custom-fields', 'revisions' ),
			'menu_icon' => AD_URL . '/resources/img/caricon.png',
));

	$car->add_taxonomy( 'location');

	$car->add_taxonomy ($this->taxonomy, array(
	'hierarchical' => true
	));

	$car->add_meta_box( 'Car_Info' , array(
		'price' => 'text',
		'engine_size' => 'text',
		'fuel_type' => 'text',
		'body_type' => 'text',
		)
	);

	$this->makes = $this->assign_models();

	add_action('init' , array( &$this ,'save_makes' ) );
	add_action('init', array ( &$this, 'save_models'), 100 );

	} // end construct

	public function assign_models() {

		$makes= array (
		'Abarth'=> array('500'),
		'Aixam' => array('Mega City'),
		'Alfa Romeo' => array('146','147','156','159','166','Brera' ,'Giulietta' ,'GT' ,'GTV' ,'Mito','Spider'),
		'Aston Martin' => array ('DB7','DB9','V8','V8'),
		'Audi' => array('80','A1','A2','A3','A4','A5','A6','A7','A8','Allroad','Cabriolet','Q3','Q5','Q7','R8','RS4','RS5','S2','S3','S4','S5','S6','S8','TT'),
		'Austin' => array('Healey','Mini'),
		'BMW' => array('1 Series','2 Series','3 Series','4 Series','5 Series','6 Series','7 Series','i3','i8','X1','X3','X5','X6','Z4')

		);

		apply_filters('carmakes', $makes);

		return $makes;

	}

	public function save_makes () {

		foreach ($this->makes as $make => $models) {
			$term='';
			$terma='';
			$termb='';
			$term= term_exists( $make , 'carmake' );
			if ($term == 0) {
			echo $make;
			echo $advert->post_type_name;
			$y=wp_insert_term ($make, 'carmake' , array('parent' => 0) );
			var_dump($y);
			} 

		}
	}

	public function save_models() {

		foreach ($this->makes as $make => $models) {

			foreach ($models as $model) {

				$term= get_term_by ( 'name', $make , 'carmake' );
				$termexists = get_term_by ('name' , $model, 'carmake' );

				if ( $termexists ) {
					$termexists = $termexists->term_id;
				} else {
					$termexists = null;
				}

				if( ! $termexists ) {
					wp_insert_term ($model , 'carmake', array('parent'=>$term->term_id) );
				}
			}

		}

	}

}
$advert= new car_post_type;

alisalem on "Only Admins and the post author can view a post, is it possible?"

$
0
0

Hello,

I have a site where my clients click on New Order icon then fill up some form (jquery) and this order will be consider as a post so the orders look like this:

http://www.mysite.com/order-1
http://www.mysite.com/order-2
http://www.mysite.com/order-3
http://www.mysite.com/order-3

Now, everyone could see the order details by pasting the links above in their browsers. I want to restrict the post visibility to admins and the client only, I know there's a way to keep posts password restricted by a password, but I wonder if it's possible to have only the admin and logged in client see his/her order for example :
http://www.mysite.com/order-2

I try to find an available plug in but I could not find any. my question is, is it difficult t make? and how much it would usually cost to make a customized plug in like that.

Thanks
A

ionurboz on "WordPress custom post_type"

$
0
0

Hi,

I'll using 'sound','video','article','image' custom types.

And I did a special new post function without admin panel. I am need, a post in the more type.

I'm tested it but array error:

/*find type*/
$post_type=array('article');

		if(isset($post_img))
			array_push($post_type, "image");
		if(isset($post_vid))
			array_push($post_type, "video");
		if(isset($post_sou))
			array_push($post_type, "sound");

............

/*select type*/
$arrays = array(
	  'post_type'	  => $post_type,

...........

$id = wp_insert_post( $arrays, $wp_error );
/*add post*/

Simple:

localhost/?video=hello and this in localhost/article=hello

Any one help me.. Sorry for bad english :)

jeich on "get_queried_object no longer working with pre_get_posts and pretty permalinks"

$
0
0

Hi!

We are experiencing the category issue referenced here ->https://core.trac.wordpress.org/ticket/26627

We applied '3.8.1' and the issue is still unresolved.

The custom query is operable with the default permalink (?cat=) option set. Our mobile barcode scan now returns the homepage. Does anyone feel up to a challenge?

nolash74 on "WP_User search by keyword - lacking wildcard in sql query"

$
0
0

WP 3.8.1

Trying to do a keyword search for user, but the SQL has no wildcards in the LIKE statements in the WHERE part. Is this a known bug?

---

` [query_fields] => DISTINCT SQL_CALC_FOUND_ROWS wp_users.*
[query_from] => FROM wp_users INNER JOIN wp_usermeta ON (wp_users.ID = wp_usermeta.user_id)
INNER JOIN wp_usermeta AS mt1 ON (wp_users.ID = mt1.user_id)
[query_where] => WHERE 1=1 AND (user_login LIKE 'a' OR user_nicename LIKE 'a') AND ( (wp_usermeta.meta_key = 'wp_capabilities' AND CAST(wp_usermeta.meta_value AS CHAR) LIKE '%gigrobot\\_booker%')
OR (mt1.meta_key = 'wp_capabilities' AND CAST(mt1.meta_value AS CHAR) LIKE '%gigrobot\\_purchaser%') )
[query_orderby] => ORDER BY display_name ASC
[query_limit] => `

robahas on "Can't save meta box input"

$
0
0

Hi - I'm making post meta boxes and I am stuck on the update piece. There is no sign of my meta en the database and I can't see what is wrong with my code:

add_action ('save_post', 'rah_save_page_meta');
function rah_save_page_meta($post_ID) {
update_post_meta( $post_ID, '_single-page-footer-text-1', $_POST['single-page-footer-text-1'] );
}

the data is collected from here, in the add_meta_box defined function:

<textarea style="width:50%; min-height:100px;" name="single-page-footer-text-1"><?php echo get_post_meta( $post->ID, '_single-page-footer-text-1', true ); ?></textarea>

I don't have to add the save_post action from within any other function do I?

visiblycreative on "Setting up special content control directly on admin Dashboard"

$
0
0

I've searched for this for quite a while with no luck, so hoping some of you nice ladies and gents here may have some advice or solutions.

I'm going to be setting up a multi-site for an organization with multiple chapters, part of the theme I've built has 3 large images and associated text on the home page that will link to specific pages.

The page categories will be the same across all instances, but the pictures and respective text can change across each instance.

I was thinking an easy way to set this up would be to create the theme with default images and text and then allow them to change the images / text directly from the dashboard. I'm trying to keep things as user-friendly as possible as the sites will be maintained by users who will mostly be new to wordpress.

So my big question is how exactly does one go about setting up special areas on the dashboard that allows for control of specific content.

Also I was thinking of setting up a support block on the dashboard as well, so along the same lines, how does one approach adding content and control control capabilities.

RichardMisencik on "Is register_post_type called only in admin?"

$
0
0

Is register_post_type function only called in admin?

I have several custom post types, each in a separate file like cpt-books.php, cpt-movies.php etc. Besides just register_post_type I have code to add metaboxes etc. for each post type.

Then in functions.php I'm requiring these files like so:

require_once('cpt-books.php');
require_once('cpt-movies.php');
...

Can I do it this way? So these files are only loaded in the admin and not on the front end?

if(is_admin()) {
require_once('cpt-books.php');
require_once('cpt-movies.php');
...
}

Is it going to work properly? Or


karthiglister on "Datetime Picker for custom plugin pages"

$
0
0

Hi there,

I'm new to Wordpress plugin development, i'm developing a custom wordpress plugin which stores, delete and update some records from database. Here i have a (DateTime)column. I want to have a datetime picker which is same as like as Addon for "Advanced Custom Fields" http://wordpress.org/plugins/acf-field-date-time-picker/

Whether it is possible to use this same plugin for custom plugin pages? How to attain this?

Thanks in Advance.

rekkette on "Default Media Slideshow"

$
0
0

Does anyone know about the default media slideshow accessible from the wordpress insert image dialog box?

Does WP offer any modifications? If so, how do I access it/modify it without screwing up any updates?

I'm already working on a child theme, so I could easily write a new file, but how do I make sure it will override the defaults?

vitalvintage on "SYN Media WooCommerce Rewards Plugin- hook: select groups, not user roles"

$
0
0

Hello,
thanks to anyone who takes the time to help.

I have the loyalty woocommerce rewards plugin. I would like to be able to modify it (hook, i think you'd call it) to be able to select from my groups i have created using the groups plugin and the woocommerce groups plugin.

when you go to woocommerce settings, click on the tab "Rewards", and scroll down, you see where you can:
"Select roles that can use rewards"
---What i want is to be able to select a group(s) than can use rewards.

Please if someone will elaborate on which file and how to accomplish this, i would be forever grateful.

webbando on "Search Permalink: replace string "?s=" to permalink structure"

impolex on "Youtube video output in comments through custom upload plugin"

$
0
0

I'm developing a pluggin for a client that will allow users to upload videos to easily upload videos and display videos for comments. Through the Youtube API users will fill out the video information and upload the video within my clients site in the comment section for the post. The pluggin will simultaneously upload the video to a community Youtube account and display the video in the comment.

The Youtube video is stored in the WordPress site as a url in the comment meta for the comment.

I have successful created the system for uploading Youtube and for storing the resulting URL.

My issue rests in attempting to display the video. I have found that WordPress does not want to do this. I have attempted four different techniques to achieve my result and none work.

Attempt 1: Processed Short Code

add_filter( 'comment_text', 'modify_comment');
    function modify_comment( $text ){

        if( $youtube = get_comment_meta( get_comment_ID(), 'youtube', true ) ) {
            $youtube = '[video src="http://www.youtube.com/watch?v='.$youtube.'" ]';
            $text = do_shortcode($youtube) . '<p>' . $text . '</p>';
        }
        return $text;
    }

Output: Clickable URL

Attempt 2: Plain Shortcode

add_filter( 'comment_text', 'modify_comment');
    function modify_comment( $text ){

        if( $youtube = get_comment_meta( get_comment_ID(), 'youtube', true ) ) {
            $youtube = '[video src="http://www.youtube.com/watch?v='.$youtube.'" ]';
            $text = $youtube . '<p>' . $text . '</p>';
        }
        return $text;
    }

Output: Shows shortcode as plain text

Attempt 3: Constructed iFrame

add_filter( 'comment_text', 'modify_comment');
    function modify_comment( $text ){

        if( $youtube = get_comment_meta( get_comment_ID(), 'youtube', true ) ) {
            $youtube = '<div><iframe title="YouTube video player" class="youtube-player" type="text/html" width="640"
height="390" src="http://www.youtube.com/watch?v='.$youtube.'" frameborder="0"
allowFullScreen></iframe></div>';
            $text = $youtube . $text;
        }
        return $text;
    }

output: Empty white box (broken iFrame)

Attempt 4: Just the URL

add_filter( 'comment_text', 'modify_comment');
    function modify_comment( $text ){

        if( $youtube = get_comment_meta( get_comment_ID(), 'youtube', true ) ) {
            $youtube = 'http://www.youtube.com/watch?v='.$youtube.';
            $text = $youtube . '<p>' . $text . '</p>';
        }
        return $text;
    }

Output: Plain Text URL (kind of expected that)

Has anyone else attempted this before? Can you think of any other ways to do this?

Viewing all 8245 articles
Browse latest View live




Latest Images