Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created portfolio page which contains a image-slid-menu for navigation. For an menu item to appear as open, javascript gets instruction like ?id=0 appended to the url. for instance portfolio/art.php?id=0. However wordpress does not allow url slug containing ? or = for pages. What should I do now? I already setup the slider with these pages working: www.gransar.net/portfolio/ www.gransar.net/portfolio/design

did I complete screw up thinking this could be easily implemented? I'm using the following: http://www.ajaxblender.com/demos/menu/imagemenu/

share|improve this question
    
Fix the JavaScript to use an hash like #id=1. –  toscho Feb 3 '13 at 8:48
    
# or = are not allowed –  Deano Feb 3 '13 at 8:53
    
Of course they are. You just have to change the script. WordPress will never see or touch it. –  toscho Feb 3 '13 at 9:01
    
when I insert those characters in the Permalink wordpress automatically reformats and removes them from the slug. How are they allowed can you explain what you do? I'm running wordpress 3.5.1 –  Deano Feb 3 '13 at 9:05
    
You have to add these per JavaScript. Look how the Anything Slider does it. –  toscho Feb 3 '13 at 9:08
show 1 more comment

2 Answers 2

Here's a potential solution using the page_link filter and testing for the presence of a meta key to add a query arg:

function wpa84303_page_query_arg( $permalink, $page, $sample ) {
    if( $query_arg = get_post_meta( $page, 'query_arg', true ) )
        $permalink = add_query_arg( 'id', '0', $permalink );
    return $permalink;
}
add_filter( 'page_link', 'wpa84303_page_query_arg', 10, 3 );

Add a custom field to the page with the key query_arg and give it any value, if the key exists then ?id=0 will be appended via the add_query_arg function.

share|improve this answer
    
Hi @Milo. This looks like a great hack! I tried and it and no longer fetches 404 error. But now wordpress is forcing a slash in between so where I should have (gransar.net/portfolio/design?id=1) I get: (gransar.net/portfolio/design/?id=1) I see this is consistent with every link in wordpress and I'm using pretty permalinks here. –  Deano Feb 5 '13 at 20:26
    
I'm using this javascript app: (ajaxblender.com/demos/menu/imagemenu) –  Deano Feb 5 '13 at 20:29
add comment

Ok... so I read the documentation for the slider and there is a function called Open that I added

<script type="text/javascript"> 
window.addEvent('domready', function(){
var myMenu = new ImageMenu($$('#imageMenu a'),{
openWidth:310, open:1, border:2, onOpen:function(e,i){window.location=(e);}
});

and everything is fine now. thanks everyone.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.