Forum Replies Created

Viewing 15 replies - 46 through 60 (of 80 total)
  • Plugin Author Mark Jansen

    (@mark-jansen)

    That is weird.

    Is there any way, that I can take a look at the install?

    Plugin Author Mark Jansen

    (@mark-jansen)

    Is WP_DEBUG on? Do you get any errors in your errorlog?

    Plugin Author Mark Jansen

    (@mark-jansen)

    What version of WP are you running and also what version of PHP?

    The plugin requires at least PHP 5.3

    Plugin Author Mark Jansen

    (@mark-jansen)

    Hello Venutius,

    thanks for downloading the plugin. How did you use it? After you’ve installed it, you have to go to extra -> WP Set Featured Image From Content and use the button there.

    Does that solve your problem?

    • This reply was modified 9 years, 11 months ago by Mark Jansen.

    I have the same problem.

    Thread Starter Mark Jansen

    (@mark-jansen)

    Resolved. Apparently the prio number had to be the same as used in adding the action.

    Forum: Hacks
    In reply to: Changing sample permalink
    Thread Starter Mark Jansen

    (@mark-jansen)

    Big big big thank you Danny.

    Turns out I didn’t read the tutorial all that well and I had to create the structure in the init hook and the permalink itself in the post_type_link hook.

    It works now with the following code:

    add_action( 'init', array( $this, 'match_permalink_structure' ) );
    add_filter( 'post_type_link', array( $this, 'better_match_permalinks' ), 10, 3 );
    public function match_permalink_structure() {
    	global $wp_rewrite;
    
    	$structure = __( 'match', 'apollo' ) . '/';
    	$structure .= '%year%/%month%/%day%/';
    	$structure .= '%matches%/';
    
    	$wp_rewrite->add_rewrite_tag( "%matches%", '([^/]+)', "matches=" );
    	$wp_rewrite->add_permastruct( 'matches', $structure, false );
    }
    public function better_match_permalinks( $permalink, $post, $leavename ) {
    	$rewritecode = array(
            '%year%',
            '%month%',
            '%day%',
            $leavename ? '' : '%matches%',
        );
    
    	$timestamp = get_field( 'match_datetime', $post->ID );
    
    	if( ! empty( $timestamp ) ) {
    		$year = date( 'Y', $timestamp );
    		$month = date( 'm', $timestamp );
    		$day = date( 'd', $timestamp );
    	} else {
    		$year = date( 'Y', strtotime( $post->post_date ) );
    		$month = date( 'm', strtotime( $post->post_date ) );
    		$day = date( 'd', strtotime( $post->post_date ) );
    	}
    
    	$rewrite_replace = array(
    		$year,
    		$month,
    		$day,
    		$post->post_name,
    	);
    
    	$permalink = str_replace($rewritecode, $rewrite_replace, $permalink);
    
    	# Flush rewrite rules, so the changes are visible.
    	//flush_rewrite_rules();
    
    	return $permalink;
    }

    Thanks!

    Forum: Hacks
    In reply to: Changing sample permalink
    Thread Starter Mark Jansen

    (@mark-jansen)

    Thanks for your answer.

    1. Hm, strange, because the permalink seems to work fine. When ever I save the post, the sample-permalink shows up correctly and the permalink works. When I pull up the permalink in the frontend, it gives me the permalink I expect.

    I based my code on this tutorial:
    http://shibashake.com/wordpress-theme/custom-post-type-permalinks-part-2

    2. I thought the post_type_link filter was designed for this, that is why I used it. I’ll have a look at the documentation you posted.

    3. I am using ACF yes, but when it is autosaved, and I forgot to mention this is only when it’s a new post, it should use the $post->post_date because $timestamp will be empty. When I dump the $post variable to the screen, it shows up, but not on autosave, then it seems to be empty. Very strange.

    When I publish or draft the post, it works fine. It’ll either get the ACF date or the post date.

    Forum: Hacks
    In reply to: Changing sample permalink
    Thread Starter Mark Jansen

    (@mark-jansen)

    The hook is called in my custom plugin using the following line:

    add_filter( 'post_type_link', array( $this, 'better_match_permalinks' ), 10, 2 );

    Your explanation about the filters makes sense, but shame that in this case you get the entire HTML, where you really wouldn’t want that πŸ˜› (well I don’t :P)

    Forum: Hacks
    In reply to: Changing sample permalink
    Thread Starter Mark Jansen

    (@mark-jansen)

    Ok, I found out perhaps the filter ‘get_sample_permalink_html’ could help me further, but I am a bit in the dark about some things.

    1. Why do I not get the structure I am building when I hook into post_type_link. Why is the link that I see different and also for example, when I hover over a link in a connected post (using Posts2Posts for that), I get the ‘ugly’ URL, not my custom permalink structure

    Perhaps if I understand that, I can fix this problem in a whole different way maybe. Maybe I am approaching this entirely wrong.

    2. get_sample_permalink_html gives me the entire html from the permalink, get_sample_permalink is also a function, but that one has no filter. Perhaps that is something that I am overlooking or is that’s intended?

    3. If I try to apply my custom permalink structure, see the code in my post above, it gives me 1970/01/01 as date. It looks like $post entirely disappears when autosave kicks in.

    So all in all, I am not that much wiser, but I hope I’m getting somewhere. Anyone who can give me another kick in the right direction?

    I have the same issue. The fix 082net posted works, but is there a way to fix this in the theme? If I ever update this plugin, chances are I will lose this fix.

    I’m having the same problem.

    Since the update to 2.0.11 which I did a few hours ago the menu generated by wp_nav_menu() is missing, it breaks the entire template. In fact, it only loads the header and then entirely breaks down at the menu.

    I’ve read a few topics about it and I’ve found that a lot of the problems are being caused by the permalink structure. The structure I’m using is /%category%/%postname%/. But this should pose no problem right?

    I’m a user of Events Calendar Pro btw, I’m not sure if that makes any difference.

    Thread Starter Mark Jansen

    (@mark-jansen)

    Ok, still not entirely what I need. Now I get the field slug, but I also want the field label.

    So I’m kinda back to square one. I now have a way to find the slug from the fields, but is there no easier way to find the label and the value of the custom fields in a group?

    Thread Starter Mark Jansen

    (@mark-jansen)

    I came up using this:

    <?php
    $group_fields = get_post_custom(4);
    $fields = explode(',', $group_fields['_wp_types_group_fields'][0]);
    foreach($fields as $field) {
        if(trim($field) != '') {
            $value = get_post_custom_values('wpcf-'.$field, get_the_ID());
            echo $value[0];
        }
    }
    ?>

    Anyone have a better solution? Otherwise I’m sticking with this.

    Thread Starter Mark Jansen

    (@mark-jansen)

    Ok I’ve only gotten so far.

    Somehow it seems I can find the field names, but not the values that go with them.

    Sooo, anyone? πŸ˜€

Viewing 15 replies - 46 through 60 (of 80 total)