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

Feritel on "has tag"

$
0
0

I need help with code that I found here:
https://wordpress.org/support/topic/using-has_tag-to-display-certain-information?replies=8.

<?php
// Array of tags to check for
$find_tags = array( 'Actress', 'Model', 'Singer' );

// Array to store matched tags
$found_tag = array();

// Seperator that sits between each result
$seperator = ',';

// If we have any one(or more) of the tags
if( has_tag( $find_tags ) ) :

	// Loop over the tag array
	foreach( $find_tags as $p_tag ) :

		// If this is a matching tag add to array
		if( has_tag( $p_tag ) )
			$found_tag[] = "<a href='http://example.com/tag/$p_tag'>$p_tag</a>";

		continue;
	endforeach;

	// Join the results together using the seperator if applicable
	echo  '<li class="occupation">Occupation: '. implode( $seperator, $found_tag ) . '</li>';
endif;
?>

This is almost what I need. But now it shows slugs of tags. How to display names of current tags in ?

$found_tag[] = "<a href='http://example.com/tag/$p_tag'>need here NAME OF TAGS</a>";

Ascker on "Add page attribute or call"

$
0
0

Hello all,
I am new here… it is hard for me to describe what I want.
I am trying to create a page inside WordPress site.
What I want

http://website.com/?page_id=450&SHORTCODE=FILE.ZIP
Now inside the WordPress there is a shortcode that call the file.
[SHORTCODE=FILE.ZIP]

Thanks for your time and your help.

imanewbe on "Add Custom Type to Menu Page"

$
0
0

I have added a custom link section to the menus page by doing the following:

add_meta_box('gallery_meta_box', __( 'Galleries' ), array(__CLASS__, 'render_add_galleries_nav_menu'), 'nav-menus', 'side', 'default' );

public static function render_add_galleries_nav_menu(){

	global $daybreak;

	$galleries = $daybreak->get_galleries( 999 );
    ?>
    <div id="gallery-archive" class="posttypediv">
        <ul class="gallery-tabs add-menu-item-tabs">
            <li class="tabs"><?php _e( 'Galleries' ); ?></li>
        </ul>
        <div class="tabs-panel tabs-panel-active">
            <ul class="categorychecklist form-no-clear">
            <?php foreach ($galleries as $key => $gallery ): ?>
                <li>
                    <label class="menu-item-title"><input type="checkbox" class="menu-item-checkbox" name="menu-item[-<?php echo $key; ?>][menu-item-object-id]" value="<?php echo $post_type->name; ?>"> <?php echo $gallery->title; ?></label>
                    <input type="hidden" class="menu-item-title" name="menu-item[-<?php echo $key; ?>][menu-item-title]" value="<?php echo $gallery->title; ?>">
                    <input type="hidden" class="menu-item-url" name="menu-item[-<?php echo $key; ?>][menu-item-url]" value="<?php echo $daybreak->get_gallery_url($gallery); ?>">
                    <input type="hidden" value="custom" name="menu-item[-<?php echo $key; ?>][menu-item-type]">
                </li>
            <?php endforeach; ?>
            </ul>
        </div>
        <p class="button-controls">
            <span class="add-to-menu">
                <input type="submit" class="button-secondary submit-add-to-menu right" value="Add to Menu" name="add-gallery-menu-item" id="submit-gallery-archive">
                <span class="spinner"></span>
            </span>
        </p>
    </div>

<?php }

This works fine. I can add these items to the menu but when I do they are added as a "Custom Link" I want to add them as a "Gallery". If I change the menu-item-type to 'gallery' then they do not get added to the menu and the page throws a JS error.

Is there some way to do this?

Ericka125 on "Excerpt Link to Preselected Dropdown Option"

$
0
0

Currently working around a Unicon theme with Visual Composer and I am querying posts. In this query each post has a custom link after the excerpt that I need to links to a preselected dropdown option on the contact page.

The method I've chosen to do this was to add Advanced Custom Fields and create a field with values that are equal to the contact form values (using Contact Form 7). In testing phase just using option1, option2, option3.

Is there a way to make it so that the link from the excerpt goes to the form and preselects the appropriate option selected in WordPress backend?

Unfortunately I am limited to using the theme, Visual Composer, and Contact Form 7, but if there are any other suggestions on easier ways to go about this, let me know.

stylep on "How to make a logo a link in my header"

$
0
0

Hi!

I know this far from calling it a hack but my theme has a logo in the header and I'm trying to make it a link (to the front page) without php or html experience.

Here's how that part in my header.php looks like:

<span class="logo"><img class="img-responsive" src="<?php echo $mt_logo; ?>" width="40" alt="" " /></span>

So, where or how should I put in a href in here?

Thanks guys for helping me out!

Cyberchicken on "get ancestors of nav_menu_item"

$
0
0

I have a page, I have a menu structure, and I am able to get to the single menu item that represents the page I'm considering.

I want to get to the topmost parent of that menu item (and then to its page).

I can do it by hand, but I was trying to use get_ancestors() like it is suggested here:
http://wordpress.stackexchange.com/questions/186195/how-to-get-the-title-of-root-li-element

After your edit I see you want the top level parent. So get_ancestors() could be helpful to you, to get the top parent. $item->ID can be used as $object_id and nav_menu_item as $object_type. get_ancestors() returns an array. Use array_reverse on it to have the top level ancestors ID at index 0.

But as a commenter noted the returned array is empty.

I thought that menu structures were taxonomies, am I wrong?

I'd like not to reinvent the wheel if possible.

PS:
documentation
https://codex.wordpress.org/Function_Reference/get_ancestors
is lagging behind code:
https://core.trac.wordpress.org/browser/tags/4.3.1/src/wp-includes/taxonomy.php#L0

anyway tracing source code
get_term($menuItem->ID, 'nav_menu_item'); generates an invalid_taxonomy error

Why is that?

battleooze on "Including wordpress functions"

$
0
0

Hello, I'm coding first plugin (and probably doing this wrong!). My current directory structure goes something like this:

-index.php has plugin declaration in comments at start of file
-standard.php has things like constant declarations & my way of including wp-load into other files which goes like this:

function iam_require_load()
{
//suppress warnings of constant
if(@constant('ABSPATH')!=null){
require_once ABSPATH.'wp-load.php';
} else {
require_once realpath('../../../').'/wp-load.php';
}
}

Which I'm assuming is a bad way to do that. Basically I made this with because I need to use things like "get_site_url()" and $wpdb in various files both in the same directory and in my templates sub directory.

I read a couple blogs which said I should not be including wp-load in a production wordpress and so I exclaimed "But then how do I include these things I need!?!?" Which lead me to the assumption that I'm doing something horribly wrong.

Any help is much appreciated! : D

clairative on "excerpt and post title issue"

$
0
0

there is a way to not display the title of the post in "excerpt"?
Thanks in advance for answers!


faust96 on "Customized image filter plugin or code"

$
0
0

Hello everybody can somebody help me?

Does anyone know a plugin or if someone could do for me, obviously not for free.

I have 150 images of paving slabs, I need a filter plugin or a code to let visitors change colours on these slabs, simply as on instagram,
these 24 filters i need:
YORK BUFF
BUFF
DEEP BUFF
YELLOW
STRONG YELLOW
NUT BROWN
LIGHT BROWN
BROWN
RUSTIC BROWN
DARK BROWN
ORANGE
PLUM
BRICK RED
TERRA COTTA
STRONG RED 130
STRONG RED Y101
STRONG BLACK
STRONG WHITE
CREAM
YORK GREEN
SAGE GREEN
OLD YORK GREEN
CHARCOAL
GRASS GREEN

PLEASE HELP!

tibi.buzdugan on "shortcode function that gets image IDs"

$
0
0

Hello,

I would like to make a shortcode that can get an array of numbers (image IDs) from within a post and make them available outside the post, so that I can make a carousel with that specific images in other places than the post's content.

Any ideas?

Thank you.

dave8528 on "fetch and display data within multi-site enviroment"

$
0
0

Hi,
I am trying to figure out how to go about solving this issue I'm facing. I have a multi-site WP environment where I have installed 4 different stand-alone ecommerce themes like below:
domain.com/auctions
domain.com/classifieds
domain.com/....etc.

I have installed a theme in the root which I like to be the face of my entire site. My question is: Is there a way to GET and POST data from each of theme ecommerce sites and display them in the root so the user will only deal with front-end/root design rather than /auctions or any others?

I am not a programmer, but I think JSON will have that capability. However, it will be out of scope of my expertise. Is there a JSON-alike pre-built "box" that you can tell it where to get the data from one end and where to display that data on the other end?

I'm sorry for my strange explanation.

Thank you.

Dariusmit on "Hook for modyfying widget content"

$
0
0

Hello,

I am new with WP development and trying to create WP plugin.

The thing I need to do is to add a html tag buttons for default text widget with ready made html templates when the user press the button. I already got the buttons, but what I can't figure out what filter/action(or none of them) should I use to make that html template (for example <div></div>) to appear into wordpress text widget's content text field?

Thanks in advance!

Regards,
Darius

dustyryan85 on "Trouble with WP_List_Table"

$
0
0

I downloaded a plugin template designed as a 'live learning' example for the WP_List_Table function.

I have learned a lot from it and I want to use parts of it to improve a plugin i am currently using.

The problem is that it has a 'sample data array' instead of a query.

Example:

<?php
/*
Plugin Name: Custom List Table Example
*/
if(!class_exists('WP_List_Table')){
    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}

class TT_Example_List_Table extends WP_List_Table {

    var $example_data = array(
            array(
                'ID'        => 1,
                'title'     => '300',
                'rating'    => 'R',
                'director'  => 'Zach Snyder'
            ),
            array(
                'ID'        => 2,
                'title'     => 'Eyes Wide Shut',
                'rating'    => 'R',
                'director'  => 'Stanley Kubrick'
            ),
            array(
                'ID'        => 3,
                'title'     => 'Moulin Rouge!',
                'rating'    => 'PG-13',
                'director'  => 'Baz Luhrman'
            ),
            array(
                'ID'        => 4,
                'title'     => 'Snow White',
                'rating'    => 'G',
                'director'  => 'Walt Disney'
            ),
            array(
                'ID'        => 5,
                'title'     => 'Super 8',
                'rating'    => 'PG-13',
                'director'  => 'JJ Abrams'
            ),
            array(
                'ID'        => 6,
                'title'     => 'The Fountain',
                'rating'    => 'PG-13',
                'director'  => 'Darren Aronofsky'
            ),
            array(
                'ID'        => 7,
                'title'     => 'Watchmen',
                'rating'    => 'R',
                'director'  => 'Zach Snyder'
            ),
            array(
                'ID'        => 8,
                'title'     => '2001',
                'rating'    => 'G',
                'director'  => 'Stanley Kubrick'
            ),
        );

		function __construct(){
        global $status, $page;

        //Set parent defaults
        parent::__construct( array(
            'singular'  => 'movie',     //singular name of the listed records
            'plural'    => 'movies',    //plural name of the listed records
            'ajax'      => false        //does this table support ajax?
        ) );

    }
}

The example data is like a movie database. The data I am after will come from the options table in wpdb.

The code I have so far is:

$example_data = get_option('limit_login_lockouts');
foreach($example_data as $value1 => $value2) {
	echo $value1 . " => " . $value2 . "<br />";
}

It echos an array just fine but I can't figure out how to make the table show the values.
70.193.96.113 => 1447706565

Here is a link to the plugin I'm getting the code from
so you can see the entire code.

I have pulled up every reference to WP_List_Table and get_options and array I could find online but still haven't figured it out.

packjazz on "I sit possible to move the Site Icon manager out of the customizer?"

$
0
0

In my WordPress multisite network I have hidden the visual customizer from the dashboard (I have my reasons).

However, I would like to utilize the new WordPress Site Icon functionality to allow my users to easily add a favicon to their sites on the network.

Anyone have any ideas how I could possibly add that same functionality into a traditional dashboard admin screen?

Ch0paRa on "Wordpress Page vs Hosting Folders"

$
0
0

Hello,
I have a custom page that is located on the same url adress as another script.
For example my page is mysite.com/email-sender this is wordpress sales page for the services but on the same root on the hosting /email-sender there is another CMS. I would like to open the wordpress page but cant change the other script path.
I would be very happy if anyone help me:)
Ttanks


aboutjquery on "Define variable for all of the template use."

$
0
0

Hello,

I have to define a dir path at function.php

define( 'THEME_DIR', get_template_directory() . '/' );

How can i use this 'THEME_DIR' for all of the template file?

So that i can use something like this in my header.php or etc.

<img src="<?php THEME_DIR ?>site-logo.png" alt="">

Thank you very much.

hamedpress on "Show child terms of current term of the taxonomy :)"

$
0
0

I need your help urgently. Thank you for your time.

I have some taxonomies (such as product, articles &...) and any taxonomy has some terms (Eg for product: mobile, book & ...), and any terms has some child terms (Eg for mobile: iPhone, sumsung, htc &... ).

Now my question: When anybody go to any term page (not child term page) such as mobile (through taxonomy.php not taxonomy-product-mobile.php), on this page all child terms of the term will be shown (iPhone, sumsung, htc &...) with their loop posts (iPhone posts).

Thanks to solve this puzzle :) Regards

lttlpnk on "Post in Page plugin with Shamrock Theme"

$
0
0

Due to my utter lack of unsuccessful tries with this plugin getting to work with the Shamrock theme, I have come here to get some help.

I've have used this shortcode in a page.
[ic_add_posts category='Dutch' paginate='yes' template='wp-content/themes/shamrock/posts_loop_template.php']

It does retrieve all the posts with the catorgory "Dutch", so that's a plus. But when I've tried multiple things to try to get it to adjust to my theme "Shamrock". Post.loop.template.php is in my theme directory with the following code.

<!-- NOTE: If you need to make changes to this file, copy it to your current theme's main
	directory so your changes won't be overwritten when the plugin is upgraded. -->

<!-- Start of Post Wrap -->
<div class="post hentry ivycat-post">

	<!-- This is the output of the post TITLE -->
	<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

	<!-- This is the output of the excerpt -->
	<div class="entry-summary">
	<!-- This will output of the featured image thumbnail  -->
		<div class="featured-image">
			<a href="<?php the_permalink(); ?>">
				<?php the_post_thumbnail( array(180,9999), array('class' => 'alignleft')); ?>
			</a>
		</div>
		<?php the_excerpt(); ?>
	</div>

	<!-- This is the output of the META information -->
	<div class="entry-utility">
		<?php if ( count( get_the_category() ) ) : ?>
			<span class="cat-links">
				<?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'shamrock' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
			</span>
			<span class="meta-sep">|</span>
		<?php endif; ?>
		<?php
			$tags_list = get_the_tag_list( '', ', ' );
			if ( $tags_list ):
		?>
			<span class="tag-links">
				<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'shamrock' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
			</span>
			<!--<span class="meta-sep">|</span> -->
		<?php endif; ?>
		<!--<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'shamrock' ), __( '1 Comment', 'shamrock' ), __( '% Comments', 'shamrock' ) ); ?></span>-->
		<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
	</div>

</div>
<!-- // End of Post Wrap -->

I've tried adding things to it and deleting, but still nothing works. Maybe it's all the class summaries within the code. I must confess, they don't exists in my css files, if I'm being honest. But I don't know where I should put them and what kind of style I should include to make it work.

Can anyone help me fix this? I've got some knowledge about html and css, but no php knowledge, other than copying code into the files.

I hope someone can help me.

pandaura on "Hide Javascript code in excerpt"

$
0
0

Is there any way to hide the Javascript code in the excerpt without manually adding a post excerpt?

djchub on ".Click Javascript/Jquery not working. onclick() exectues only after 2 clicks"

$
0
0

Hi Guys,

I'm trying to apply this http://callmenick.com/_development/expanding-search-bar/ into my wordpress website. One issue I have been facing throughout while implementing anything in wordpress is that .click function defined in the JS file doesnt execute.
For example, neither of these work :-

labelEl.addEventListener("click",function(){
    if (classie.has(searchEl,"focus")) {
        classie.remove(searchEl,"focus");
        classie.remove(labelEl,"active");

or

j('#overlay-menu').click(function() {
          j('.overlay').addClass('overlay-open');
          j('.menuButton').hide();
       });

Coming back to the feature I'm trying to currently implement( expanding search bar), I've loaded the js files and in Firefox (Inspect element) I can see the JS files being loaded in the header. I assigned an onclick() function to the div and the code is executing perfectly. But now I need to click the button twice.

The fiddle :- http://codepen.io/djchub/pen/BoMeEZ

I've spent two nights over this. Any help would be much appreciated.

Thanks

Viewing all 8245 articles
Browse latest View live


Latest Images