Making wordpress menu remain highlighted (class="current-page-item" in the menu) for a category listing (not a page) - wordpress

I have a site that I have completely customized the theme.
Unfortunately the theme and the way it's set up doesn't like you to view the actual page permalink for both the blog and the portfolio to view its content.
Regular pages work fine:
site.com/about
site.com/contact
However, if you go to /portfolio or /blog the pages show up blank
As a result, I had to use appearance>menu to make a custom menu that links to:
/category/portfolio/#all
/category/blog
This makes the content now show up, the only problem is when they click on the portfolio or the blog, wordpress thinks that it's not actually viewing that page, so the tab in the main menu doesnt remain highlighted (to show you what page youre currently on)
Does anyone have any idea how to fix this?
http://eastcoastefx.com/ggqq
Thank you :)

I have done this before. It's not pretty, but it works if both items are WordPress pages.
// hack the queried_object_id for wp_list_pages
global $wp_query;
$queried_object_id = $wp_query->queried_object_id;
if ($season_page) {
// ensure season pages have Season highlighed in nav
$wp_query->queried_object_id = 22;
}
wp_list_pages($args);
// set queried_object_id back to the original
$queried_object_id = $queried_object_id;
I'd be interested to know if you found anything better on the WordPress forum per Mike Schinkel's comment as the above is clearly a hack.

Related

Remove sub menus from the admin view for a plugin that registers a custom post type

I know there are 357,982 other posts about this BUT they all kinda lack something ie. an actual example that works for those of us who don't write 4,594,334 line of code every day.
SO - As it stands the scenerio is:
A plugin that registers a custom post type
A sub-menu you want to hide
What next?
The best solution I have found is actually pretty easy and requires a bit of inspection of the source and a good understanding of what to look for.
In this example woocommerce is registering the custom post type 'product' with a sub-menu that appears as 'Product Options'. We want to hide this for non-admin users.
Doing an inspection of the menu items we find that the hyperlink for the parent menu is 'edit.php?post_type=event_ticket' - looking a little further we see that the hyperlink for the sub-menu is 'https://websitename.com/wp-admin/edit.php?post_type=product&page=product_attributes'
We will use the 'add_action' hook as shown below. Please note that we are using the url for the parent menu however we are ONLY using the page parameter for the child.
add_action('admin_menu', 'remove_menu_pages', 999);
function remove_menu_pages()
{
if (current_user_can('manage_options') == false)
{
//1st parameter is parent URL | second is the 'page' parameter from the child url
remove_submenu_page('edit.php?post_type=product', 'product_attributes');
}
}
Add this to your functions.php and then login as a non-admin user and the submenu should now be hidden.

Full Screen iframe in Wordpress

I am working SEO on wordpress, my goal is to rent out a page by using iframe to put my clients webpage all over mine, but in wordpress if I use iframe the toolbar and widgets remain there. Is there way of hiding everything and just leaving another web page on top of mine? Thank you for your time.
Please note that using an iframe might not contribute much in terms of SEO. Have a read through this article. What might be relevant:
iFrames are merely referencing the content, instead of duplicating it. When robots crawl the site and register the iframe tag, they will attribute the original source with any SEO credit instead of the page using the embedded content – i.e. the page with the iFrame.
That said:
To hide the admin toolbar, either disable it in your profile, via /wp-admin/profile.php. Or do this programmatically (in functions.php) with something like:
if (!is_admin) {
add_filter('show_admin_bar', '__return_false');
}
To remove widgets, try following the tutorial on justintadlock.com, in functions.php add something like:
add_filter( 'sidebars_widgets', 'disable_all_widgets' );
function disable_all_widgets( $sidebars_widgets ) {
$sidebars_widgets = array( false );
return $sidebars_widgets;
}

Fields disappear for a specific theme

I'm new to drupal, so sorry in advance or any mistake, feel free to correct.
I don't really know what exactly that I have done cause the problem, but content's fields (for all content types)
is not being shown (the pages are empty beside the title).
When I edit the information it appears.
In the past the information appeared.
It happens only for a specific theme (business_theme), for other themes (drupal's default) the info' appears.
any idea or help will be great
You need to assign Main page content block to a region that already exists in your theme.
First; Declare the region in your theme's .info file.
regions[content] = Main Content
Second; Print the region inside your page.tpl.php file.
print render($page['content']);
Last; Assign the Main page content to the region from the Blocks manager page. ?q=admin/structure/block
After further investigation, It seems that when our own theme is being the default, no node.tpl.php is being called (does that makes sense?).
I add the code
<?php
print '<pre>';
var_dump(get_defined_vars());
print '</pre>';
?>
to each node*.tpl.php file and cleared all caches.
when our theme is working no changes appeared,
when enabling batrick theme the added code was working.
This happens only in the page itself, i.e. when entering to localhost/drupal/node...
in the front page the added code worked for both themes.
any ideas?
tnx

Wordpress show sub menu items on index page

I am using wordpress and on the page "sidebar.php" I have the following code:
<?php wp_list_pages('post_type=wiki&depth=1'); ?>
It works great but what I need to do it that what I click on a Menu item on the sidebar I need the sub items to display on the main page.
UPDATE:
What I basically need to do is to have the first level items on the left (As it currently is), and when those links are clicked then the sub items of those items will be listed on the index.php (main page).
I am using the wp-wiki plugin to display the pages as wiki pages but the actual but the list is the same, just showing as a different type:
post_type=wiki
Can anyone help please?
Thanks
<?php
wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->ID.'&depth=0');
?>
There's several ways you can accomplish this. WordPress actually has an example of exactly what you're looking to do in the Codex. (link - the last example in that section, right above the "List subpages even if on a subpage" heading)
There's several ways to do this though - that's just one example. But that code above, you just pop into your sidebar.php file. You can also create a widget out of it. And as someone else mentioned, you can use the new menu system for WordPress (but you can indeed, make it dynamic.) But the above example in the Codex is the simplest method.
Actually, an easier method would be just to list all subpages and use CSS to hide and show the child items based on what page you're on. The classes are already set up for you. Just view your source code and you can see it. So you'd do something like:
`li ul.children {display:none; }
li.current_page ul.children { display:block; }`
and variations thereof.
What about using the new menu function in wp 3?
That way you could include your type with any sub page you want (won't be dynamic though) and then add your favorite javascript or good css to show those sub-pages.

Modifying the menu navigation to include the domain

Some background if you want to see why I'm doing what I'm doing:
I have a client who wanted a new blog done with Wordpress on a separate subdomain. Their existing website is on Drupal, which I have had 0 experience with prior to this. They have a pretty extensive navigation on that site (multiple levels), so rather than create duplicates of nav menus that would need updated on both wordpress and drupal, I am using YQL to pull in the whole navigation onto the Wordpress website. I know this isn't great for SEO, but at this point I'm not worried about that.
The issue I have is that all of the links on the Drupal website do not include the http://domain.com so that none of the links work on the blog site, because they're going to relative pages on that subdomain that don't exist.
So in summary, what I'm trying to accomplish:
I need each href that Drupal is generating to begin with 'http://domain.com'. Currently they just start with '/pagename'. I have no clue what Drupal version the site is on nor on how to find it, sorry. The site is using Drupal's Nice Menu plugin as well. I've been digging through the files for a couple of hours now, and can't figure out where I need to make the change. Please help! Thanks
Edit: dobeerman mentioned using custom_url_rewrite_outbound to settings.php. This seems to accomplish close to what I want. I tried adding this to the end of settings.php:
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
global $user;
$path = 'http://www.reillypainting.com/'.$path;
}
However, the end result of an href in the menu becomes this example:
href="/http%3A/%252Fwww.reillypainting.com/services/sell/rent-your-house"
So the other code generating Drupal's menu is trying to escape the :// and it's also still adding a / to the beginning of the href. Anyone know how to avoid this?
Drupal has function custom_url_rewrite_outbound you can add to settings.php
Use this code:
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
$options['absolute'] = 1;
}

Resources