Get setting form wordpress customizer and display in a url - wordpress

How can I create a custom url like this :
www.my-wordpress-blog.com/?layout=fullwidth
www.my-wordpress-blog.com/?layout=grid
www.my-wordpress-blog.com/?layout=list
See Example what excepted as output,
http://themes.themegoods2.com/letsblog/?layout=fullwidth
http://gleedthemes.com/themes/elora/?layout=2
I tried looking on Google, but no "how to" tutorials show up for anything like this.

How create custom URL
Step:1 Login to admin panel and go to "Appreance->Menu"
Step:2 Use the Custom Links panel to add a custom link to your menu, such as a link to an external website.
Step:3 Simply type in the website URL in the URL field and the menu name in the Link Text field.
Step:4 Click the Add to Menu button when done. Use the same steps outlined previously to adjust the order of the menu item and click the Save Menu button at the top or bottom of the screen to save your changes.
Please refer following for more information,
http://www.templatemonster.com/help/wordpress-add-custom-link-menu.html#gref
How To set Layout page
Add page from page menu
Select a Right side Page attribute select a template from there.
publish page and visit a menu from front side.
Final Solution Suggested By [Sociopath]
Path : wp-content/themes/yourtheme/functions.php
add this code at the end of file.
if( ! function_exists( 'themename_demo_set_the_header_layout' ) ){
/**
* Set the demo header layout from child theme.
* #param unknown_type $header
* #return Ambigous <NULL, string>
*/
function themename_demo_set_the_header_layout( $header = 'layout1' ) {
$header = isset( $_GET['header'] ) ? trim( $_GET['header'] ) : null;
// Add more checking conditions here.
return $header;
}
add_filter( 'themename_set_my_header_layout', 'themename_demo_set_the_header_layout', 10, 1 );
}

Related

WordPress add Login/Logout to menu editor

Ok, so I found this code, which I modified to suit my needs. Btw, I'm using WooCommerce, which explains the "wc" in some of the function calls:
//Add login/logout link to primary menu
add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'primary') {
$items .= '<li>Log Out</li>';
}
elseif (!is_user_logged_in() && $args->theme_location == 'primary') {
$items .= '<li>Log In</li>';
}
return $items;
This adds the login/logout menu items, and they work fine. However, they're stuck at the end of the menu, at the moment. I'd like to be able to edit the position using the editor in wp-admin. The solution I thought of was to maybe just create login and logout pages, and use header location redirects with those lines of code in them to get to the proper URLs, but the issue I see with that is that there will always be a login item and logout, no matter what status the user is currently in. Would there maybe be a way to dynamically add a site-wide CSS rule to hide the opposite menu item, based on the log in status?
Or is there an easier way?
Not the best idea but you can try.
Create in wp-admin menu section new menu item like "Custom Link"
Log Out
http://www.example.com/account/customer-logout/
Log In
http://www.example.com/account/
And add a custom class to a WordPress menu item to manage visibility
For example, you will see "logged-in" class on the body of the page and hide "Log In" link or change it to "Account" with the same link.

Change Wordpress feed <link> for one specific tag

I have an external page that reads a RSS feed for a tag. I can't change anything on the external page, so the challenge is to change the RSS feed on my side to match the requirements.
On the external page the 3 latest posts for a tag are shown, and at the end of the section (note: not after each post but after all 3 posts) there is a "View all" link. This link receives its value from the element in the feed, which is by default set to my blog homepage, e.g. http://myblog.com). For this specific tag the link should be http://myblog.com/tag/myspecialtag.
The requirement is that the "View all" link links to the tag page instead of the homepage.
My idea was to add a condition to the element to change the URL for this specific category. I tried to change the feed template as recommended here: Customizing feeds, but for some reason it doesn't change the template at all. The code I tried is the following:
remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', 'change_feed_rss2', 10, 1 );
function change_feed_rss2( $for_comments ) {
$rss_template = get_template_directory() . '/feeds/feed-custom_rss2.php';
if( file_exists( $rss_template ) )
load_template( $rss_template );
else
do_feed_rss2( $for_comments ); // Call default function
}
Of course I created the custom feed template and stored it in the feeds directory in my theme.
As this didn't work I tried looking into filters/hooks but I couldn't find anything helpful regarding my issue. Any ideas on how to best solve this issue?
I came up with the following solution:
I created a new custom page template custom_rss-feed.php and copied the code from wp-includes/feed-rss.php into it. I assigned this template to a new page. Additionally I added a filter to get_bloginfo_rss like the following:
function alter_bloginfo_rss($value, $key) {
if ( $key === "url" &&
is_page_template("custom_rss-feed.php")
) {
return $value . "/my/custom/url";
}
return $value;
}
add_filter("get_bloginfo_rss", "alter_bloginfo_rss", 10, 2);

Top-level menu item to edit a specific page

I'm not sure if this is possible or advisable, but I'd like to have a top-level menu item on the sidebar in the admin dashboard that links to a specific page within wordpress for editing.
Maybe there's a better way of doing this... here's the functionality I'm after:
I have a page called "Upgrade Contents" where my client can edit the contents of their upgrade package sitewide. I'd like them to be able to edit this page directly from the admin dashboard, like a setting page. Problem is, I don't know how to add a link to edit this page to the admin AND I already have everything set up with ACF using this page.
Is adding a link easy to do or should I just scrap it and make a settings page for my theme and add THAT to the admin?
To add a link at the top level of the menu you can add an item to the global $menu array, like this:
function link_to_user_settings() {
global $menu;
$title = 'User Settings';
$url = 'URL_OF_YOUR_PAGE';
$position = 73;
$permission = 'read';
$icon = 'dashicons-admin-links';
$menu[$position] = array( $title, $permission, $url, '', 'menu-top', '', $icon );
}
add_action( 'admin_menu', 'link_to_user_settings' );
Change the variables accordingly to your needs.
The $position var is where you want the link to appear based on the default positions you can find at the add_menu_page() documentation (in my example 73 means after the Users menu item).

How to add page URL to list of pages in WordPress admin panel?

Currently, by default, the following columns appear in the list of pages in the WordPress admin panel:
Title
Author
Comments
Date
and because I have AIO SEO installed:
SEO Title
SEO Description
SEO Keywords
Is there a way to have WordPress also display the URL to the page (at least the part of the URL that is created when the page itself is created)?
The page url is actually already there by default, it's just hiding. When you hover over a page title, several links appear below the title -- edit, quick edit, trash, view. View is the hyperlink to the page, which you can click to view the page, or right click and copy the link address to use elsewhere.
Otherwise, if you are using a custom/child theme, you could add the following to your functions.php file:
add_filter('manage_page_posts_columns', 'my_custom_column', 10);
add_action('manage_page_posts_custom_column', 'add_my_custom_column', 10, 2);
function my_custom_column($defaults) {
$defaults['url'] = 'URL';
return $defaults;
}
function add_my_custom_column($column_name, $post_id) {
if ($column_name == 'url') {
echo get_permalink( $post_id );
}
}
Note: This just creates a text url to your page.
Also note, you do not want to edit your functions.php file directly if you are using a theme you did not create, as it will be overwritten when you update. If you want to add this to an existing theme, I'd suggest looking into child themes.
This is helpful. I would only improve the output slightly by removing the site url and just showing the page. Takes up less space and less to weed through visually.
if ($column_name == 'url') {
$siteURL=get_site_url($post_id);
$link= get_permalink( $post_id );
echo str_replace($siteURL,"",$link);
}

How to change the home page title text in navigation menu?

I have created a wordpress site. The home page appears in the navigation menu with the name of "Home".
I want to change this text to some other text so that in the navigation menu, it did not appear as a "Home", instead it should appear as some other text.
How will I change this text?
So, in order to Change the name of Home button go to:
wp-includes/post-template.php
Look for:
// Show Home in the menu
if ( isset($args['show_home']) && ! empty($args['show_home']) ) {
if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )
$text = __('Home');
Do you see last "Home" text ? There you go, change it to whatever you want.
If we are talking about the default theme "Twenty Twelve":
Open ../twentytwelve/functions.php
Find twentytwelve_page_menu_args function.
Replace
$args['show_home'] = true;
with
$args['show_home'] = "Your name";
Hoooray!!! :)
Try this ...
http://en.forums.wordpress.com/topic/changing-text-of-home-link-to-something-else
It depends on each theme you would like to use.
For Twenty Twelve what you have to do is to set a front end page (static page) and give it a name.
then you copy functions.php to your child theme's folder and then find this:
/**
* Makes our wp_nav_menu() fallback -- wp_page_menu() -- show a home link.
*
* #since Twenty Twelve 1.0
*/
function twentytwelve_page_menu_args( $args ) {
if ( ! isset( $args['show_home'] ) )
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'twentytwelve_page_menu_args' );
and change this single line:
$args['show_home'] = false;
Alternatively,
a simple solution is to go to Menus tab on the left and play with the menu options there, you can add your own if you like.
Several years later since asking this question you can do this from the admin panel. There's a good explanation on this website. Basically you need to go to:
http://yourDomain/wp-admin > Appearance > Menus. Then, under the Menu structure you will find Home - click and change the title to whatever you want. I hope this helps someone ))

Resources