Forum Replies Created

Viewing 15 replies - 31 through 45 (of 50 total)
  • Richard

    (@richardcoffee)

    I just got off the phone with my partner in crime, which I can say because we do themes together. Our conversation went something like this:

    Me: “Did you take a look at that post?”
    Him: “Yes, looked okay. Got a couple of questions though.”
    Me: “Oh?”
    Him: “I know you. Did you test those two examples before you posted?”
    Me: “Of course!”
    Him “Okay. Where?”
    Me: “On that real estate site we did earlier this year.”
    Him: “I see. You do realize that site actually works, right?”
    Me: “Oh.”
    Him: “How about the one you wrote for him?”
    Me: “Um..gimme a minute”

    Me: “No.”
    Him: “No, what?”
    Me: “It didn’t work on his site.”
    Him: “Well?”
    Me: “Darn.”

    Richard

    (@richardcoffee)

    oops, the test should have been:

    site.com/index.php?taxonomy=mods&term=general&name=test

    Richard

    (@richardcoffee)

    How silly of me (slap forehead). Of course, I think I understand now.

    I believe what you need is a rewrite rule. I am, however, somewhat of a novice with those, but am willing to give it a go. Hopefully, maybe someone with more experience with them will chime in.

    In the (albeit limited) experimentation I have done with rewrites I have found it easier for me if I figure out what kind of rule I need first. I go about this by figuring out a url that will give me the page I want, such as site.com/index.php?taxonomy=tax_name&term=term_name, or possibly
    site.com/index.php?post_type=post_type_slug&name=post_name. I would expect the first example to give me an archive page, and the second example to give me a single post page. I can then derive the rewrite rule index that I need. This has always worked for me, but YMMV.

    In the example you gave, /mods/general/test, if the test of site.com/taxonomy=mods&term=general&name=test works, then I would expect the rewrite rule to look like this:

    index: (.+?)/(.+?)/(.+?)/?$
    rule: /index.php?taxonomy=$matches[1]&term=$matches[2]&name=$matches[3]

    This should give a single post page, and you might need separate rules for archives, searches, authors, etc.

    I add rules using one of the rewrite filters, like ‘post_rewrite_rules’, so that they are always added whenever the rules get flushed.

    Like I said though, I am no expert on this, and may be pointing you in a completely wrong direction for what you need.

    Richard

    (@richardcoffee)

    It is possible. Go to this site, https://fluidity.the-creative-collective.com, and click on the link under Recent Posts on the right. There is only one post, so the pages will look the same, but the address bar will be different.

    This is a theme I am currently working on, and it uses sub-categories not unlike what you want.

    What is your permalink setting? The one above is set to /%category%/%postname%/. It would make a difference. Without that, the only way I would know have to achieve what you want is by creating rewrite rules, but I any help I could give with that would be spotty at best.

    Richard

    (@richardcoffee)

    Richard

    (@richardcoffee)

    You need to use a different slug for the taxonomy. WordPress’ rewrite rules will match the post type slug first, and thus never look at the taxonomy.

    On another note, is there a reason you are assigning a 0 priority in the add_action calls? I wouldn’t think you would normally need that…

    Richard

    (@richardcoffee)

    Wow, with the other links, I must have missed the pastebin one. Dang.

    Having looked over the pastebin, I have noticed a few things:

    The post_type array has two ‘rewrite’ indexes. Not sure which one that PHP will assign to the array, but you will only end up with one of them.

    I notice you are passing the ‘taxonomies’ array also. I am not sure but reading the codex seems to indicate the taxonomies have to have already been registered prior to using passing that array. Personally, I always opt to use register_taxonomy_for_object_type instead.

    I normally only pass the slug in the taxonomy rewrite array. Your value for ‘with_front’ is the default value, while ‘feeds’ and ‘pages’ are, as far as I aware, not valid values for the taxonomy rewrite array. I would think that wordpress just ignore those two.

    Hope this is helpful.

    Richard

    (@richardcoffee)

    Without seeing the code you are using, it is difficult to offer any specific advice.

    I would venture to suggest that your rewrites should be ‘en/category’ for ‘postsen_category’, and ‘en/tag’ for ‘postsen_tag’. This alone may not be enough to get it to work, depending on what else you are doing. For instance, you may (or may not) need ‘taxonomy-postsen_category.php’ and ‘taxonomy-postsen_tag.php’ pages.

    Maybe someone else here can offer ore advice. Good luck!

    richard

    Forum: Hacks
    In reply to: delete_option with button?
    Richard

    (@richardcoffee)

    This would need to be handled using a two part method.

    First part is deleting the image actually being viewed. Use javascript to find and remove it in the DOM. All this will do is remove it from the screen, giving the user the impression the image has been deleted.

    Second part is actually deleting the image. You can achieve this using both javascript and php. When removing the image from the screen, you will need to save an image identifier in a hidden field that gets sent back to the server when the page is saved. In the server php code, check if the field has data and process that data to actually delete the image.

    Hope this helps

    Richard

    (@richardcoffee)

    You should be able to achieve this using the rewrite api at https://codex.www.ads-software.com/Rewrite_API

    I have used this with some success, but am no expert by any means. I have always had to experiment some to get the results I want. Sounds like you may want to use the ‘{$permastruct}_rewrite_rules’ hook.

    Forum: Hacks
    In reply to: delete_option with button?
    Richard

    (@richardcoffee)

    Richard

    (@richardcoffee)

    You are using conflicting parameters and that is why it isn’t working for you. Try this instead:

    $args=array('post_type' => $post_type,
    	     'tax_query' => array(array('taxonomy' => 'status_ba',
    					'field'    => 'slug',
    					'terms'    => array('available','pending'))),
    	      			'post_status' => 'publish',
    	      			'posts_per_page' => -1,
    				);
    $my_query = new WP_Query($args);

    Also, I don’t believe you need that foreach loop, or at least it is not germane to the question.

    Richard

    (@richardcoffee)

    You would probably be better off using a different method, such as is_user_logged_in(), or something along those lines. If you are going to serve content based upon who the user is, then you should be looking at that, rather then what page they are on.

    Forum: Hacks
    In reply to: Taxonomy problem
    Richard

    (@richardcoffee)

    Just registering your taxonomy is not enough. You also have to link it to the custom post type, like so:

    register_taxonomy_for_object_type('categorias_personaje','personajes');

    Place this immediately after the call to register_taxonomy.

    Richard

    (@richardcoffee)

    You need to declare the variables as global before you give them a value.

Viewing 15 replies - 31 through 45 (of 50 total)