Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

James on "WordPress Category Walker - How To Split Categories Into Multiple Columns?"

0
0

I'm attempting to build a mega-menu for my WordPress blog. As part of the menu I'm using a custom category walker to list categories as links in a dropdown div (ParentCat>ChildCats). What I'd like to do is split the child categories into multiple columns so they fill the full width of my dropdown div. I know I can do this by just floating the list elements but I'd like the order to be vertical (1, 2 and 3 in the first column and 4, 5 and 6 in second column etc).

So far I have the below walker that structures my dropdown div and displays the child categories in one column. Can anybody provide any input as to how or if I can split the child categories up into multiple columns? I've seen several articles regarding this but I can't figure out how to apply the logic inside a walker?

class Navigation_Catwalker extends Walker_Category {

// Configure the start of each level
function start_lvl(&$output, $depth = 0, $args = array()) {
    $output .= "";
}

// Configure the end of each level
function end_lvl(&$output, $depth = 0, $args = array()) {
    $output .= "";
}

// Configure the start of each element
function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0) {

    // Set the category name and slug as a variables for later use
    $cat_name = esc_attr( $category->name );
    $cat_name = apply_filters( 'list_cats', $cat_name, $category );
    $cat_slug = esc_attr( $category->slug );

    // Configure the output for the top list element and its URL
    if ( $depth === 0 ) {
        $link = '<a class="parent-category-dropdown" href="' . esc_url( get_term_link($category) ) . '"' . '>' . $cat_name . '</a>';
        $indent = str_repeat("\t", $depth);
        $output .= "\t<li class='parent-category " . $cat_slug . "'>$link\n<div class='category-dropdown'>\n<span class='parent-category-title'>" . $cat_name . "</span>\n$indent<ul class='submenu'>\n";
    }

    // Configure the output for lower level list elements and their URL's
    if ( $depth > 0 ) {
        $link = '<a href="' . esc_url( get_term_link($category) ) . '"' . '>' . $cat_name . '</a>';
        $output .= "\t<li class='sub-category'>$link\n";
    }

}

// Configure the end of each element
function end_el(&$output, $page, $depth = 0, $args = array() ) {
    if ( $depth === 0 ) {
        $indent = str_repeat("\t", $depth);
        $output .= "$indent</ul>\n</div>\n";
    }
    if ( $depth > 0 ) {
        $output .= "</li>";
    }

}

}

Thanks,
James


xymalf on "Please help menu creation"

0
0

Does anybody know the full php code to create a Menu with an options page and an applications page please. If I search the net they are only showing some code like most of my books. I even purchased some menu building software but no luck either. I am sure this skeleton code can't be too long.

angela.marie.giaco@gmail.com on "Social Media Pop Up (Preferably without Plugin)"

0
0

Here is what I am trying to do:

When a customer gets to a specific page, I would like a popup to appear on page load. Within the popup I would like to display an area to share a website on Facebook (and Twitter, Google Plus if possible). The trick is that the page to be shared is the homepage, not the current page that has displayed the popup. Once they have shared on Facebook I would like the customer to be redirected to another of our pages (that will have a code on it for a discount).

I'd preferably like to use as least amount of plugins as possible, but if that's the only option then I can deal with it. If anyone could advise me on the best way to accomplish this, I would very much appreciate it.

My site is http://clearchoicephotobooth.com.

Thank you.

brisimmons105 on "link to latest post in category on a category list?"

0
0

I've got a code that currently lists out all my categories, in alphabetical order, with anchors to each letter.

When I click on one of the categories, it links me to the category archives page by default, but is there a way to link it directly to the latest post in that category instead of the category archive page?

Here is my code currently:

http://pastebin.com/mVJtv67x

SLAFmultimedia on "Have to refresh twice to see changes"

0
0

Hi you reading,

I'm presently doing a website for someone, and his website has 2 sections. I want to change the main_navigation menu in relation to the section the user is currently on.

I did this by creating a child-theme and editing the header-main-menu.php file. Here's how I do it:

<?php

if(!$data['ubermenu']) {
$sectionname = get_permalink();
$menu_id = (strpos($sectionname, 'technical-furniture') !== false ? 3 : 8);
$mods = get_option("theme_mods_avada-child");
$mods['nav_menu_locations']['main_navigation'] = $menu_id;
update_option("theme_mods_avada-child", $mods);

echo $main_menu;
} else {
uberMenu_direct( 'main_navigation' );
}
?>

I don't know why, but I have to refresh twice for the menu to change.FYI, I did disable the cache in the wp-config.php file by writing :

define('DISABLE_CACHE', true);

at the end of the file.

Do you guys have any idea what causes this or how to troubleshoot myself?

Thanks thank you for taking the time to read my question.

SLAF

xmelky on "Wordpress and qTranslate email text change?"

0
0

I have a website with Wordpress and qTranslate plugin, problem is if the user want to reset his password the email text is not correct in German language, i edited it in:
/wp-content/languages/de_DE.po
/wp-content/plugins/woocommerce/i18n/languages/woocommerce-de_DE.po

The text what i want to edit is Someone requested that the password be reset for the following account: Every time if i want to reset mail a see old translation, what i do wrong here?

uritz on "Run a function only once - share variable across templates PHP"

0
0

I have a function (say call_api()) which reaches out to API and stores value in a variable which I then want to share across templates. I have tried a number of ways :

1) Using Session Variable and sharing the variable, but the function is called more than once.

2) Using static variable to run function only once.

Now, I want the function to run once when user loads the website, and store the value in a function which is stored in a variable which can be shared across various templates.

I have done extensive Google Search but was unable to come up with a solution. Can anyone please point me to the right direction ?

The River on "How to fix duplicate post in many categories?"

0
0

I'm trying to make a function to get 5 post of any category to display in main page of a wordpress site. But in main page, some posts are duplicate with others. Please help me fix it. Thank all!

Here my site: womenonline.us Here my function:

function special_index_hoz($cat){
    $posts= array();

    $posts=query_posts('showposts=5&cat='.$cat);
    echo '<div id="box-top">';
    $id=$posts[0]->ID;

    $args = array(
    'post_type' => 'attachment',
    'numberposts' => null,
    'post_status' => null,
    'post_parent' => $id
    ); 

    $img_src = get_posts($args)[0]->guid;
            echo '<img src="'.$img_src.'" width="80" height="100"/>';
            echo '<h1><a href="'.get_permalink($id).'">'.wp_trim_words($posts[0]->post_title,10).'</a></h1>';
            echo '<p>'.wp_trim_words($posts[0]->post_content,25).'<p>';
            echo '</div>';
            echo '<div id="box-bottom">
<ul>';
            for ($i=1;$i<5;$i++)
            {
            $id=$posts[$i]->ID;
            $args['post_parent']=$id;
            $img_src = get_posts($args)[0]->guid;
            echo '<a href="'.get_permalink($id).'">
<li><img src="'.$img_src.'" width="80" height="100" />';
            echo '<p>'.wp_trim_words($posts[$i]->post_content,6).'</p></li>
</a>';
            //echo '<div id="line-bottom"></div>';
    }
    echo '</ul>
</div>';
}

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code has now been permanently damaged by the forum's parser.]


AliceWonderFull on "Is WP_PLUGIN_URL still broken ??"

0
0

Hi, I came across some reports that WP_PLUGIN_URL was broken sometimes giving a non SSL url from SSL pages, but those reports seem to be several years old.

They suggest using plugins_url() instead of the constant.

Is that still the case or has it been fixed?

http://wordpress.org/support/topic/dont-use-wp_plugin_url

seems to say it is fixed 11 months ago, is it really or are there still issues in some contexts?

Tree2054 on "Multisite - How can I hook into user_registered via Admin panel?"

0
0

I am cross posting this here since it is probably a better place to do it:
WP StackExchange post

I am integrating with an external authentication server using the user_register action. We manually create users via the admin panel and do not allow self registration. Now I need to handle a similar scenario but in a sub-site while using Multisite.

I was running through a debugger and noticed that when posting a new user in multisite mode to wp-admin/user-new.php, there are no actions fired that work the same way as user_register. The closest I see is the wpmu_validate_user_signup filter but I know that is not the right place to do this.

I log into the admin panel as a super admin, select the site via the My Sites menu, then go to Users > Add New.

The function wpmu_signup_user does the insert and it does not contain any do_action calls

Is this an oversight in WordPress core for not providing such an action or am I doing it wrong? If it is the former I will open a ticket about adding a new action. I am using 3.9.1

xymalf on "ch3mlm-sub-menu"

0
0
<?php

/*
  Plugin Name: options menu
  Plugin URI:
  Description: chapter 3 multi-menu
  Author: adrian
  Version: 1.0
  Author URI: http://www.xymalf.com

warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'ch3mlm_my_complex_submenu' not found or invalid function name in C:\wamp\www\WPDev\wp-includes\plugin.php on line 470
 */

add_action ( 'admin_menu', 'ch3mlm_admin_menu' );

function ch3mlm_admin_menu() {

add_menu_page( 'My complex plugin configuration',
'My Complex Plugin', 'manage options', 'ch3mlm-main-menu', 'ch3mlm_my_complex_main', plugins_url( 'myplugin.png', _FILE_ ));

add_submenu_page( 'ch3mlm-main-menu',
'My Complex Menu Sub-Config Page', 'Sub-Config Page',
'manage_options', 'ch3mlm-sub-menu',
'ch3mlm_my_complex_submenu' );

}

when I click on the sub menu page I am getting an error as in header even though file ch3mlm-sub-menu.php exists in the plugin directory.

Chrisago on "Exclude posts with specific slug."

0
0

Hi all,

I am trying to exclude portfolio items which have the slug name "featured".
I guess any amends needs to be done on these lines of code below.

Any help will be appreciated!

function recent_porfolios() {
    global $post;
    $exclude = $post->ID;
    rewind_posts();

    // Create a new WP_Query() object
    $wpcust = new WP_Query(
        array(
            'post_type' => array('portfolio'),
            'post__not_in' => array($exclude),
	    'orderby' => 'rand',
            'showposts' => '4' ) // or 10 items.
        );

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

baptiste_ on "Probleme user wordpress"

0
0

Hello,

I've a problem with WP.
I can't get logged username from an external page. I've include wp-blog-header.php and usse this code :

<?php

if ( !is_user_logged_in() ) {

echo "connécté";

} else {

echo "Non conncté";

}
?>

But nothing happened.

Thanks for your help.

kash1990 on "how to fetch latest post from a specific category"

0
0

I have this code:

<a href="<?php echo get_home_url()?>?cat=15">

								<?php
									$post = get_post(214, ARRAY_A);
								?>
									<?php echo get_the_post_thumbnail($post['ID'], 'full', array('class' => 'img-responsive green')); ?>
									<p class="tag-text">
										<small><?php echo $post["post_content"]?>

										</small>

									</p>
								</a>

How can I replace this code to display latest post content from a specific category, not from the category which is provided in the code. It is working as a static content now. Want to make it dynamic

Brent on "getting total post count of custom post type in custom taxonomy?"

0
0

Hi,

I need to display something like this on my custom taxonomy archive page:
Number of items: x, where x is the post count on the current page.

I have 3 "categories" in my custom taxonomy and each of them have an individual "archive page"

What code should I put in my taxonomy-taxonomyname.php file?

Thanks in advance


MartinChillz on "Ready! Pricing table alignment"

0
0

Hello, all please help me align Ready Pricing table plugin table, theoretically its already aligned middle, but in the live site it isnt showing.. Anyone knows the problem?

<p style="text-align: center;"><br class="none" />[ready-pricing-tables id=67]</p>

this is the code in the post. Thanks

Sincerely,
Martin

[Moderator Note: No bumping. If it's that urgent after just 3 hours, please consider hiring someone instead.]

a4jp.com on "Can someone see why my inspiration menu drop down doesn't show up?"

0
0

I made my own child theme to a theme and now it looks nothing like the original but I some how turned off the drop downs of the top main navigation. I can see the bits in the code so they are there but they just don't show on the mouse over. Can someone see why they don't show up?

Regards,

Glen

http://a4jp.com

Mayeenul Islam on "How to load scripts in WP Admin from plugins"

0
0

I know the question have been asked many times, but none of them doesn't actually meet me. So without saying bla bla, I'm saying my situation first:

In my plugin, I need to add a custom post type, then to load custom meta box, and to sort the meta box in good way I need to add them using jquery tab.
From these, I could implement the first two:
- Making CPT
- Adding Meta box and could save meta data

But I'm unable to load the jquery thing for the tabs.

As I know I can utilize the default jquery and jquery-ui-tabs and enqueue them in admin end. But when I'm using:

function load_scripts() {
   wp_enqueue_script( 'jquery' );
   wp_enqueue_script( 'jquery-ui-tabs' );
}
add_action('admin_enqueue_scripts', 'load_scripts');

The tabs are not working. But if I load my custom jquery and ui scripts from my plugin, the tabs are working...but,
but, the tab is working only on the "Add new PostType" page (post-new.php), but NOT WORKING on PostType Edit Page (post.php).

So here comes the million dollar question:
* How can i load scripts in wp admin from plugin - the right way?

xymalf on "how do I write the function to open the page?"

0
0
<?php

/*
Plugin Name: Menu Test
Plugin URI: http://codex.wordpress.org/Adding_Administration_Menus
Description: Menu Test
Author: Codex authors
Author URI: http://example.com

warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'boj_menuexample_settings_page' not found or invalid function name in C:\wamp\www\WPDev\wp-includes\plugin.php on line 470
*/

add_action( 'admin_menu', 'boj_menuexample_create_menu' );

function boj_menuexample_create_menu() {

add_menu_page( 'My Plugin Settings Page', 'Menu Example Settings','manage_options', _FILE_, 'boj_menuexample_settings_page', plugins_url( '/images/wp-icon.png', _FILE__));

}

add_action( 'about_menu', 'boj_menuexample_about_page');
function boj_menuexample_about_page() {
add_submenu_page( _FILE_, 'About My Plugin', 'About', 'manage_options',_FILE_.'_about', boj_menuexample_about_page);

}

add_action( 'uninstall_menu', 'boj_menuexample_uninstall_page');
function boj_menuexample_uninstall_page() {

add_submenu_page( _FILE_,'Uninstall My Plugin', 'uninstall', 'manage_options',
_FILE_.'_uninstall', boj_menuexample_uninstall_page);

}

?>

Endlyss on "Any Possible problems with the following? Archive Template (Code Review)"

0
0

First off, I apologize if this ends up duplicating. I posted a post similar to this about an hour ago and it has yet to publish...I the looked around and realized that I should have used pastebin (which may be why it isn't publishing, because there was quite a bit of code in it :P

Anyways...
Hey guys...at the moment I am building a theme that I am going to try to provide for free to the community. I have been working with wordpress for the past year and a half now, but this is my first theme that will be distributed to many people, where I have to provide a lot of customization ability, so I am learning a lot as I go.

The blankslate theme that I downloaded did not offer as much as I would have preferred in terms of easy customization. Took a lot of hacking to get smaller things to do exactly what I wanted, and basically figured I would be better off doing it from scratch and just keeping the default functions that were bundled in the bare theme.

Problem is that I am not quite sure if my substitution would cause any problems? Or if it is even considered good practice?

I set up the archive loop as follows, and was wondering if there is anything that I am missing (such as an already built-in wordpress function)
But basically takes the URL structure for the Archive page that you land on, dissects it, divides it up into year/month/day and then applies a date_query based on it.

Is the following "okay" to use in terms of efficiency and would it be considered an acceptable template?

The Function that "slices" the URL into year/month/day

The Template Part for the Archives

Archive.php Template that pulls everything together

The Result

Functions well no matter what date you select, or whether you just pick a day or a month or a year...but I am curious as to if my code would be considered acceptable or if there is an easier, more modern or simply a wordpress function that takes what I did and condenses it.

What I want to keep: Maximum control over custom elements (this is why I used a query loop...I've always found it the easiest to add whatever elements I want, where I want.)

Viewing all 8245 articles
Browse latest View live




Latest Images